<?php
define("EW_PAGE_ID", "list", TRUE); // Page ID
define("EW_TABLE_NAME", 'view_reg_master_netsales', TRUE);
?>
<?php 
session_start(); // Initialize session data
ob_start(); // Turn on output buffering
?>
<?php include "ewcfg50.php" ?>
<?php include "ewmysql50.php" ?>
<?php include "phpfn50.php" ?>
<?php include "view_reg_master_netsalesinfo.php" ?>
<?php include "userfn50.php" ?>
<?php include "tb_usersinfo.php" ?>
<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // Always modified
header("Cache-Control: private, no-store, no-cache, must-revalidate"); // HTTP/1.1 
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
?>
<?php

// Open connection to the database
$conn = ew_Connect();
?>
<?php
$Security = new cAdvancedSecurity();
?>
<?php
if (!$Security->IsLoggedIn()) $Security->AutoLogin();
if (!$Security->IsLoggedIn()) {
	$Security->SaveLastUrl();
	Page_Terminate("login.php");
}
?>
<?php

// Common page loading event (in userfn*.php)
Page_Loading();
?>
<?php

// Page load event, used in current page
Page_Load();
?>
<?php
$view_reg_master_netsales->Export = @$_GET["export"]; // Get export parameter
$sExport = $view_reg_master_netsales->Export; // Get export parameter, used in header
$sExportFile = $view_reg_master_netsales->TableVar; // Get export file, used in header
?>
<?php
if ($view_reg_master_netsales->Export == "excel") {
	header('Content-Type: application/vnd.ms-excel');
	header('Content-Disposition: attachment; filename=' . $sExportFile .'.xls');
}
if ($view_reg_master_netsales->Export == "csv") {
	header('Content-Type: application/csv');
	header('Content-Disposition: attachment; filename=' . $sExportFile .'.csv');
}
?>
<?php

// Paging variables
$nStartRec = 0; // Start record index
$nStopRec = 0; // Stop record index
$nTotalRecs = 0; // Total number of records
$nDisplayRecs = 20;
$nRecRange = 10;
$nRecCount = 0; // Record count

// Search filters
$sSrchAdvanced = ""; // Advanced search filter
$sSrchBasic = ""; // Basic search filter
$sSrchWhere = ""; // Search where clause
$sFilter = "";

// Master/Detail
$sDbMasterFilter = ""; // Master filter
$sDbDetailFilter = ""; // Detail filter
$sSqlMaster = ""; // Sql for master record

// Set up records per page dynamically
SetUpDisplayRecs();

// Handle reset command
ResetCmd();

// Get search criteria for advanced search
$sSrchAdvanced = AdvancedSearchWhere();

// Get basic search criteria
$sSrchBasic = BasicSearchWhere();

// Build search criteria
if ($sSrchAdvanced <> "") {
	if ($sSrchWhere <> "") $sSrchWhere .= " AND ";
	$sSrchWhere .= "(" . $sSrchAdvanced . ")";
}
if ($sSrchBasic <> "") {
	if ($sSrchWhere <> "") $sSrchWhere .= " AND ";
	$sSrchWhere .= "(" . $sSrchBasic . ")";
}

// Save search criteria
if ($sSrchWhere <> "") {
	if ($sSrchBasic == "") ResetBasicSearchParms();
	if ($sSrchAdvanced == "") ResetAdvancedSearchParms();
	$view_reg_master_netsales->setSearchWhere($sSrchWhere); // Save to Session
	$nStartRec = 1; // Reset start record counter
	$view_reg_master_netsales->setStartRecordNumber($nStartRec);
} else {
	RestoreSearchParms();
}

// Build filter
$sFilter = "";
if ($sDbDetailFilter <> "") {
	if ($sFilter <> "") $sFilter .= " AND ";
	$sFilter .= "(" . $sDbDetailFilter . ")";
}
if ($sSrchWhere <> "") {
	if ($sFilter <> "") $sFilter .= " AND ";
	$sFilter .= "(" . $sSrchWhere . ")";
}

// Set up filter in Session
$view_reg_master_netsales->setSessionWhere($sFilter);
$view_reg_master_netsales->CurrentFilter = "";

// Set Up Sorting Order
SetUpSortOrder();

// Export data only
if ($view_reg_master_netsales->Export == "xml" || $view_reg_master_netsales->Export == "csv") {
	ExportData();
	Page_Terminate(); // Terminate response
}

// Set Return Url
$view_reg_master_netsales->setReturnUrl("view_reg_master_netsaleslist.php");
?>
<?php include "header.php" ?>
<?php if ($view_reg_master_netsales->Export == "") { ?>
<script type="text/javascript">
<!--
var EW_PAGE_ID = "list"; // Page id

//-->
</script>
<script type="text/javascript">
<!--

function ew_ValidateForm2(fobj) {
	var infix = "";
	elm = fobj.elements["x" + infix + "_LogDate"];
	if (elm && !ew_CheckDate(elm.value)) {
		if (!ew_OnError(elm, "Incorrect date, format = yyyy/mm/dd - Log Date"))
			return false; 
	}
	for (var i=0;i<fobj.elements.length;i++) {
		var elem = fobj.elements[i];
		if (elem.name.substring(0,2) == "s_" || elem.name.substring(0,3) == "sv_")
			elem.value = "";
	}
	return true;
}

//-->
</script>
<script type="text/javascript">
<!--
var firstrowoffset = 1; // First data row start at
var lastrowoffset = 0; // Last data row end at
var EW_LIST_TABLE_NAME = 'ewlistmain'; // Table name for list page
var rowclass = 'ewTableRow'; // Row class
var rowaltclass = 'ewTableAltRow'; // Row alternate class
var rowmoverclass = 'ewTableHighlightRow'; // Row mouse over class
var rowselectedclass = 'ewTableSelectRow'; // Row selected class
var roweditclass = 'ewTableEditRow'; // Row edit class

//-->
</script>
<script type="text/javascript">
<!--
var ew_DHTMLEditors = [];

//-->
</script>
<link rel="stylesheet" type="text/css" media="all" href="calendar/calendar-win2k-1.css" title="win2k-1" />
<script type="text/javascript" src="calendar/calendar.js"></script>
<script type="text/javascript" src="calendar/lang/calendar-en.js"></script>
<script type="text/javascript" src="calendar/calendar-setup.js"></script>
<script language="JavaScript" type="text/javascript">
<!--

// Write your client script here, no need to add script tags.
// To include another .js script, use:
// ew_ClientScriptInclude("my_javascript.js");

 

//-->

</script>
<?php } ?>
<?php if ($view_reg_master_netsales->Export == "") { ?>
<?php } ?>
<?php

// Load recordset
$bExportAll = (defined("EW_EXPORT_ALL") && $view_reg_master_netsales->Export <> "");
$bSelectLimit = ($view_reg_master_netsales->Export == "" && $view_reg_master_netsales->SelectLimit);
if (!$bSelectLimit) $rs = LoadRecordset();
$nTotalRecs = ($bSelectLimit) ? $view_reg_master_netsales->SelectRecordCount() : $rs->RecordCount();
$nStartRec = 1;
if ($nDisplayRecs <= 0) $nDisplayRecs = $nTotalRecs; // Display all records
if (!$bExportAll) SetUpStartRec(); // Set up start record position
if ($bSelectLimit) $rs = LoadRecordset($nStartRec-1, $nDisplayRecs);
?>
<p><span class="phpmaker" style="white-space: nowrap;">View: Register Master (NetSales)
<?php if ($view_reg_master_netsales->Export == "") { ?>
&nbsp;&nbsp;<a href="view_reg_master_netsaleslist.php?export=excel">Export to Excel</a>
&nbsp;&nbsp;<a href="view_reg_master_netsaleslist.php?export=csv">Export to CSV</a>
&nbsp;&nbsp;<a href="view_reg_master_netsaleslist.php?Refresh=0">Refresh</a>
<?php } ?>
</span></p>
<?php if ($view_reg_master_netsales->Export == "") { ?>
<?php if ($Security->IsLoggedIn()) { ?>
<form name="fview_reg_master_netsaleslistsrch" id="fview_reg_master_netsaleslistsrch" action="view_reg_master_netsaleslist.php" onSubmit="return ew_ValidateForm2(this);">
<?php
LoadAdvancedSearch(); // Load advanced search

// Render for search
$view_reg_master_netsales->RowType = EW_ROWTYPE_SEARCH;
RenderRow();
?>
<table class="ewBasicSearch">
	<tr>
		<td><span class="phpmaker">Log Date</span></td>
		<td><span class="ewSearchOpr">=<input type="hidden" name="z_LogDate" id="z_LogDate" value="="></span></td>
		<td>			
			<table border="0" cellspacing="0" cellpadding="0"><tr>
				<td><span class="phpmaker">
<input type="text" name="x_LogDate" id="x_LogDate" title="" value="<?php echo $view_reg_master_netsales->LogDate->EditValue ?>"<?php echo $view_reg_master_netsales->LogDate->EditAttributes() ?>>
&nbsp;<img src="images/ew_calendar.gif" id="cx_LogDate" alt="Pick a Date" style="cursor:pointer;cursor:hand;">
<script type="text/javascript">
Calendar.setup(
{
inputField : "x_LogDate", // ID of the input field
ifFormat : "%Y/%m/%d", // the date format
button : "cx_LogDate" // ID of the button
}
);
</script>
</span></td>
			</tr></table>			
		</td>
	</tr>
	<tr>
		<td><span class="phpmaker">Reg ID</span></td>
		<td><span class="ewSearchOpr">contains<input type="hidden" name="z_RegID" id="z_RegID" value="LIKE"></span></td>
		<td>			
			<table border="0" cellspacing="0" cellpadding="0"><tr>
				<td><span class="phpmaker">
<select id="x_RegID" name="x_RegID"<?php echo $view_reg_master_netsales->RegID->EditAttributes() ?>>
<!--option value="">Please Select</option-->
<?php
if (is_array($view_reg_master_netsales->RegID->EditValue)) {
	$arwrk = $view_reg_master_netsales->RegID->EditValue;
	$rowswrk = count($arwrk);
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($view_reg_master_netsales->RegID->AdvancedSearch->SearchValue) == strval($arwrk[$rowcntwrk][0])) ? " selected" : "";	
?>
<option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
<?php echo $arwrk[$rowcntwrk][1] ?>
</option>
<?php
			}
}
?>
</select>
</span></td>
			</tr></table>			
		</td>
	</tr>
</table>
<table class="ewBasicSearch">
	<tr>
		<td><span class="phpmaker">
			<input type="text" name="<?php echo EW_TABLE_BASIC_SEARCH ?>" id="<?php echo EW_TABLE_BASIC_SEARCH ?>" size="20" value="<?php echo ew_HtmlEncode($view_reg_master_netsales->getBasicSearchKeyword()) ?>">
			<input type="Submit" name="Submit" id="Submit" value="Search (*)">&nbsp;
			<input type="Button" name="Reset" id="Reset" value="   Reset   " onclick="ew_ClearForm(this.form);if (this.form.<?php echo EW_TABLE_BASIC_SEARCH_TYPE ?>) this.form.<?php echo EW_TABLE_BASIC_SEARCH_TYPE ?>[0].checked = true;">&nbsp;
			<a href="view_reg_master_netsaleslist.php?cmd=reset">Show all</a>&nbsp;
			<a href="view_reg_master_netsalessrch.php">Advanced Search</a>&nbsp;
		</span></td>
	</tr>
	<tr>
	<td><span class="phpmaker"><input type="radio" name="<?php echo EW_TABLE_BASIC_SEARCH_TYPE ?>" id="<?php echo EW_TABLE_BASIC_SEARCH_TYPE ?>" value="" <?php if ($view_reg_master_netsales->getBasicSearchType() == "") { ?>checked<?php } ?>>Exact phrase&nbsp;&nbsp;<input type="radio" name="<?php echo EW_TABLE_BASIC_SEARCH_TYPE ?>" id="<?php echo EW_TABLE_BASIC_SEARCH_TYPE ?>" value="AND" <?php if ($view_reg_master_netsales->getBasicSearchType() == "AND") { ?>checked<?php } ?>>All words&nbsp;&nbsp;<input type="radio" name="<?php echo EW_TABLE_BASIC_SEARCH_TYPE ?>" id="<?php echo EW_TABLE_BASIC_SEARCH_TYPE ?>" value="OR" <?php if ($view_reg_master_netsales->getBasicSearchType() == "OR") { ?>checked<?php } ?>>Any word</span></td>
	</tr>
</table>
</form>
<?php } ?>
<?php } ?>
<?php
if (@$_SESSION[EW_SESSION_MESSAGE] <> "") {
?>
<p><span class="ewmsg"><?php echo $_SESSION[EW_SESSION_MESSAGE] ?></span></p>
<?php
	$_SESSION[EW_SESSION_MESSAGE] = ""; // Clear message
}
?>
<form method="post" name="fview_reg_master_netsaleslist" id="fview_reg_master_netsaleslist">
<?php if ($view_reg_master_netsales->Export == "") { ?>
<table>
	<tr><td><span class="phpmaker">
	</span></td></tr>
</table>
<?php } ?>
<?php if ($nTotalRecs > 0) { ?>
<table id="ewlistmain" class="ewTable">
<?php
	$OptionCnt = 0;
?>
	<!-- Table header -->
	<tr class="ewTableHeader">
		<td valign="top" style="white-space: nowrap;">
<?php if ($view_reg_master_netsales->Export <> "") { ?>
ID
<?php } else { ?>
	<a href="view_reg_master_netsaleslist.php?order=<?php echo urlencode('ID') ?>&ordertype=<?php echo $view_reg_master_netsales->ID->ReverseSort() ?>">ID<?php if ($view_reg_master_netsales->ID->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($view_reg_master_netsales->ID->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></a>
<?php } ?>
		</td>
		<td valign="top" style="white-space: nowrap;">
<?php if ($view_reg_master_netsales->Export <> "") { ?>
Log Date
<?php } else { ?>
	<a href="view_reg_master_netsaleslist.php?order=<?php echo urlencode('LogDate') ?>&ordertype=<?php echo $view_reg_master_netsales->LogDate->ReverseSort() ?>">Log Date<?php if ($view_reg_master_netsales->LogDate->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($view_reg_master_netsales->LogDate->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></a>
<?php } ?>
		</td>
		<td valign="top" style="white-space: nowrap;">
<?php if ($view_reg_master_netsales->Export <> "") { ?>
Reg ID
<?php } else { ?>
	<a href="view_reg_master_netsaleslist.php?order=<?php echo urlencode('RegID') ?>&ordertype=<?php echo $view_reg_master_netsales->RegID->ReverseSort() ?>">Reg ID<?php if ($view_reg_master_netsales->RegID->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($view_reg_master_netsales->RegID->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></a>
<?php } ?>
		</td>
		<td valign="top" style="white-space: nowrap;">
<?php if ($view_reg_master_netsales->Export <> "") { ?>
User Name
<?php } else { ?>
	<a href="view_reg_master_netsaleslist.php?order=<?php echo urlencode('UserName') ?>&ordertype=<?php echo $view_reg_master_netsales->UserName->ReverseSort() ?>">User Name&nbsp;(*)<?php if ($view_reg_master_netsales->UserName->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($view_reg_master_netsales->UserName->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></a>
<?php } ?>
		</td>
		<td valign="top" style="white-space: nowrap;">
<?php if ($view_reg_master_netsales->Export <> "") { ?>
Store Net
<?php } else { ?>
	<a href="view_reg_master_netsaleslist.php?order=<?php echo urlencode('StoreNet') ?>&ordertype=<?php echo $view_reg_master_netsales->StoreNet->ReverseSort() ?>">Store Net<?php if ($view_reg_master_netsales->StoreNet->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($view_reg_master_netsales->StoreNet->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></a>
<?php } ?>
		</td>
		<td valign="top" style="white-space: nowrap;">
<?php if ($view_reg_master_netsales->Export <> "") { ?>
Short Over
<?php } else { ?>
	<a href="view_reg_master_netsaleslist.php?order=<?php echo urlencode('ShortOver') ?>&ordertype=<?php echo $view_reg_master_netsales->ShortOver->ReverseSort() ?>">Short Over<?php if ($view_reg_master_netsales->ShortOver->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($view_reg_master_netsales->ShortOver->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></a>
<?php } ?>
		</td>
		<td valign="top" style="white-space: nowrap;">
<?php if ($view_reg_master_netsales->Export <> "") { ?>
Diff IPP
<?php } else { ?>
	<a href="view_reg_master_netsaleslist.php?order=<?php echo urlencode('DiffIPP') ?>&ordertype=<?php echo $view_reg_master_netsales->DiffIPP->ReverseSort() ?>">Diff IPP<?php if ($view_reg_master_netsales->DiffIPP->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($view_reg_master_netsales->DiffIPP->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></a>
<?php } ?>
		</td>
		<td valign="top" style="white-space: nowrap;">
<?php if ($view_reg_master_netsales->Export <> "") { ?>
Log IPP
<?php } else { ?>
	<a href="view_reg_master_netsaleslist.php?order=<?php echo urlencode('LogIPP') ?>&ordertype=<?php echo $view_reg_master_netsales->LogIPP->ReverseSort() ?>">Log IPP<?php if ($view_reg_master_netsales->LogIPP->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($view_reg_master_netsales->LogIPP->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></a>
<?php } ?>
		</td>
		<td valign="top">
<?php if ($view_reg_master_netsales->Export <> "") { ?>
Bank IPP
<?php } else { ?>
	<a href="view_reg_master_netsaleslist.php?order=<?php echo urlencode('BankIPP') ?>&ordertype=<?php echo $view_reg_master_netsales->BankIPP->ReverseSort() ?>">Bank IPP<?php if ($view_reg_master_netsales->BankIPP->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($view_reg_master_netsales->BankIPP->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></a>
<?php } ?>
		</td>
		<td valign="top" style="white-space: nowrap;">
<?php if ($view_reg_master_netsales->Export <> "") { ?>
Diff XRead
<?php } else { ?>
	<a href="view_reg_master_netsaleslist.php?order=<?php echo urlencode('DiffXreading') ?>&ordertype=<?php echo $view_reg_master_netsales->DiffXreading->ReverseSort() ?>">Diff XRead<?php if ($view_reg_master_netsales->DiffXreading->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($view_reg_master_netsales->DiffXreading->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></a>
<?php } ?>
		</td>
		<td valign="top" style="white-space: nowrap;">
<?php if ($view_reg_master_netsales->Export <> "") { ?>
MO Amt
<?php } else { ?>
	<a href="view_reg_master_netsaleslist.php?order=<?php echo urlencode('MOAmt') ?>&ordertype=<?php echo $view_reg_master_netsales->MOAmt->ReverseSort() ?>">MO Amt<?php if ($view_reg_master_netsales->MOAmt->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($view_reg_master_netsales->MOAmt->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></a>
<?php } ?>
		</td>
		<td valign="top">
<?php if ($view_reg_master_netsales->Export <> "") { ?>
Bank MO
<?php } else { ?>
	<a href="view_reg_master_netsaleslist.php?order=<?php echo urlencode('BankMO') ?>&ordertype=<?php echo $view_reg_master_netsales->BankMO->ReverseSort() ?>">Bank MO<?php if ($view_reg_master_netsales->BankMO->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($view_reg_master_netsales->BankMO->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></a>
<?php } ?>
		</td>
		<td valign="top">
<?php if ($view_reg_master_netsales->Export <> "") { ?>
Diff Copay
<?php } else { ?>
	<a href="view_reg_master_netsaleslist.php?order=<?php echo urlencode('DiffCopay') ?>&ordertype=<?php echo $view_reg_master_netsales->DiffCopay->ReverseSort() ?>">Diff Copay<?php if ($view_reg_master_netsales->DiffCopay->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($view_reg_master_netsales->DiffCopay->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></a>
<?php } ?>
		</td>
		<td valign="top" style="white-space: nowrap;">
<?php if ($view_reg_master_netsales->Export <> "") { ?>
Check Amt
<?php } else { ?>
	<a href="view_reg_master_netsaleslist.php?order=<?php echo urlencode('CheckAmt') ?>&ordertype=<?php echo $view_reg_master_netsales->CheckAmt->ReverseSort() ?>">Check Amt<?php if ($view_reg_master_netsales->CheckAmt->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($view_reg_master_netsales->CheckAmt->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></a>
<?php } ?>
		</td>
		<td valign="top" style="white-space: nowrap;">
<?php if ($view_reg_master_netsales->Export <> "") { ?>
Credit Amt
<?php } else { ?>
	<a href="view_reg_master_netsaleslist.php?order=<?php echo urlencode('CreditAmt') ?>&ordertype=<?php echo $view_reg_master_netsales->CreditAmt->ReverseSort() ?>">Credit Amt<?php if ($view_reg_master_netsales->CreditAmt->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($view_reg_master_netsales->CreditAmt->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></a>
<?php } ?>
		</td>
		
		<td valign="top">
<?php if ($view_reg_master_netsales->Export <> "") { ?>
Bank CC
<?php } else { ?>
	<a href="view_reg_master_netsaleslist.php?order=<?php echo urlencode('BankCC') ?>&ordertype=<?php echo $view_reg_master_netsales->BankCC->ReverseSort() ?>">Bank CC<?php if ($view_reg_master_netsales->BankCC->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($view_reg_master_netsales->BankCC->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></a>
<?php } ?>
		</td>
		<td valign="top" style="white-space: nowrap;">
<?php if ($view_reg_master_netsales->Export <> "") { ?>
Lunch Amt
<?php } else { ?>
	<a href="view_reg_master_netsaleslist.php?order=<?php echo urlencode('LunchAmt') ?>&ordertype=<?php echo $view_reg_master_netsales->LunchAmt->ReverseSort() ?>">Lunch Amt<?php if ($view_reg_master_netsales->LunchAmt->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($view_reg_master_netsales->LunchAmt->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></a>
<?php } ?>
		</td>
		<td valign="top" style="white-space: nowrap;">
<?php if ($view_reg_master_netsales->Export <> "") { ?>
Payout Amt
<?php } else { ?>
	<a href="view_reg_master_netsaleslist.php?order=<?php echo urlencode('PayoutAmt') ?>&ordertype=<?php echo $view_reg_master_netsales->PayoutAmt->ReverseSort() ?>">Payout Amt<?php if ($view_reg_master_netsales->PayoutAmt->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($view_reg_master_netsales->PayoutAmt->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></a>
<?php } ?>
		</td>
		<td valign="top" style="white-space: nowrap;">
<?php if ($view_reg_master_netsales->Export <> "") { ?>
340B
<?php } else { ?>
	<a href="view_reg_master_netsaleslist.php?order=<?php echo urlencode('340B') ?>&ordertype=<?php echo $view_reg_master_netsales->z340B->ReverseSort() ?>">340B<?php if ($view_reg_master_netsales->z340B->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($view_reg_master_netsales->z340B->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></a>
<?php } ?>
		</td>
		<td valign="top" style="white-space: nowrap;">
<?php if ($view_reg_master_netsales->Export <> "") { ?>
R2(CI)
<?php } else { ?>
	<a href="view_reg_master_netsaleslist.php?order=<?php echo urlencode('R2(CI)') ?>&ordertype=<?php echo $view_reg_master_netsales->R228CI29->ReverseSort() ?>">R2(CI)<?php if ($view_reg_master_netsales->R228CI29->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($view_reg_master_netsales->R228CI29->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></a>
<?php } ?>
		</td>
		<td valign="top" style="white-space: nowrap;">
<?php if ($view_reg_master_netsales->Export <> "") { ?>
Kinray
<?php } else { ?>
	<a href="view_reg_master_netsaleslist.php?order=<?php echo urlencode('Kinray') ?>&ordertype=<?php echo $view_reg_master_netsales->Kinray->ReverseSort() ?>">Kinray<?php if ($view_reg_master_netsales->Kinray->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($view_reg_master_netsales->Kinray->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></a>
<?php } ?>
		</td>
		<td valign="top" style="white-space: nowrap;">
<?php if ($view_reg_master_netsales->Export <> "") { ?>
Cash Adj
<?php } else { ?>
	<a href="view_reg_master_netsaleslist.php?order=<?php echo urlencode('CashAdj') ?>&ordertype=<?php echo $view_reg_master_netsales->CashAdj->ReverseSort() ?>">Cash Adj<?php if ($view_reg_master_netsales->CashAdj->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($view_reg_master_netsales->CashAdj->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></a>
<?php } ?>
		</td>
		<td valign="top" style="white-space: nowrap;">
<?php if ($view_reg_master_netsales->Export <> "") { ?>
Over Amt
<?php } else { ?>
	<a href="view_reg_master_netsaleslist.php?order=<?php echo urlencode('OverAmt') ?>&ordertype=<?php echo $view_reg_master_netsales->OverAmt->ReverseSort() ?>">Over Amt<?php if ($view_reg_master_netsales->OverAmt->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($view_reg_master_netsales->OverAmt->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></a>
<?php } ?>
		</td>
<?php if ($view_reg_master_netsales->Export == "") { ?>
<?php } ?>
	</tr>
<?php
if (defined("EW_EXPORT_ALL") && $view_reg_master_netsales->Export <> "") {
	$nStopRec = $nTotalRecs;
} else {
	$nStopRec = $nStartRec + $nDisplayRecs - 1; // Set the last record to display
}
$nRecCount = $nStartRec - 1;
if (!$rs->EOF) {
	$rs->MoveFirst();
	if (!$view_reg_master_netsales->SelectLimit) $rs->Move($nStartRec - 1); // Move to first record directly
}
$RowCnt = 0;
while (!$rs->EOF && $nRecCount < $nStopRec) {
	$nRecCount++;
	if (intval($nRecCount) >= intval($nStartRec)) {
		$RowCnt++;

	// Init row class and style
	$view_reg_master_netsales->CssClass = "ewTableRow";
	$view_reg_master_netsales->CssStyle = "";

	// Init row event
	$view_reg_master_netsales->RowClientEvents = "onmouseover='ew_MouseOver(this);' onmouseout='ew_MouseOut(this);' onclick='ew_Click(this);'";

	// Display alternate color for rows
	if ($RowCnt % 2 == 0) {
		$view_reg_master_netsales->CssClass = "ewTableAltRow";
	}
	LoadRowValues($rs); // Load row values
	$view_reg_master_netsales->RowType = EW_ROWTYPE_VIEW; // Render view
	RenderRow();
?>
	<!-- Table body -->
	<tr<?php echo $view_reg_master_netsales->DisplayAttributes() ?>
	 ondblclick="window.location.href='ActivityLog3.php?ID=<?php echo addslashes(html_entity_decode(base64_encode($view_reg_master_netsales->ID->ViewValue))) ;?>' ">
		<!-- ID -->
		<td<?php echo $view_reg_master_netsales->ID->CellAttributes() ?>>
<div<?php echo $view_reg_master_netsales->ID->ViewAttributes() ?>><?php echo $view_reg_master_netsales->ID->ViewValue ?></div>
</td>
		<!-- LogDate -->
		<td<?php echo $view_reg_master_netsales->LogDate->CellAttributes() ?>>
<div<?php echo $view_reg_master_netsales->LogDate->ViewAttributes() ?>><?php echo $view_reg_master_netsales->LogDate->ViewValue ?></div>
</td>
		<!-- RegID -->
		<td<?php echo $view_reg_master_netsales->RegID->CellAttributes() ?>>
<div<?php echo $view_reg_master_netsales->RegID->ViewAttributes() ?>><?php echo $view_reg_master_netsales->RegID->ViewValue ?></div>
</td>
		<!-- UserName -->
		<td<?php echo $view_reg_master_netsales->UserName->CellAttributes() ?>>
<div<?php echo $view_reg_master_netsales->UserName->ViewAttributes() ?>><?php echo $view_reg_master_netsales->UserName->ViewValue ?></div>
</td>
		<!-- StoreNet -->
		<td<?php echo $view_reg_master_netsales->StoreNet->CellAttributes() ?>>
<div<?php echo $view_reg_master_netsales->StoreNet->ViewAttributes() ?>><?php echo $view_reg_master_netsales->StoreNet->ViewValue ?></div>
</td>
		<!-- ShortOver -->
		<td<?php echo $view_reg_master_netsales->ShortOver->CellAttributes() ?>>
<div<?php echo $view_reg_master_netsales->ShortOver->ViewAttributes() ?>><?php echo $view_reg_master_netsales->ShortOver->ViewValue ?></div>
</td>
		<!-- DiffIPP -->
		<td<?php echo $view_reg_master_netsales->DiffIPP->CellAttributes() ?>>
<div<?php echo $view_reg_master_netsales->DiffIPP->ViewAttributes() ?>><?php echo $view_reg_master_netsales->DiffIPP->ViewValue ?></div>
</td>
		<!-- LogIPP -->
		<td<?php echo $view_reg_master_netsales->LogIPP->CellAttributes() ?>>
<div<?php echo $view_reg_master_netsales->LogIPP->ViewAttributes() ?>><?php echo $view_reg_master_netsales->LogIPP->ViewValue ?></div>
</td>
		<!-- BankIPP -->
		<td<?php echo $view_reg_master_netsales->BankIPP->CellAttributes() ?>>
<div<?php echo $view_reg_master_netsales->BankIPP->ViewAttributes() ?>><?php echo $view_reg_master_netsales->BankIPP->ViewValue ?></div>
</td>
		<!-- DiffXreading -->
		<td<?php echo $view_reg_master_netsales->DiffXreading->CellAttributes() ?>>
<div<?php echo $view_reg_master_netsales->DiffXreading->ViewAttributes() ?>><?php echo $view_reg_master_netsales->DiffXreading->ViewValue ?></div>
</td>
		<!-- MOAmt -->
		<td<?php echo $view_reg_master_netsales->MOAmt->CellAttributes() ?>>
<div<?php echo $view_reg_master_netsales->MOAmt->ViewAttributes() ?>><?php echo $view_reg_master_netsales->MOAmt->ViewValue ?></div>
</td>
		<!-- BankMO -->
		<td<?php echo $view_reg_master_netsales->BankMO->CellAttributes() ?>>
<div<?php echo $view_reg_master_netsales->BankMO->ViewAttributes() ?>><?php echo $view_reg_master_netsales->BankMO->ViewValue ?></div>
</td>
		<!-- DiffCopay -->
		<td<?php echo $view_reg_master_netsales->DiffCopay->CellAttributes() ?>>
<div<?php echo $view_reg_master_netsales->DiffCopay->ViewAttributes() ?>><?php echo $view_reg_master_netsales->DiffCopay->ViewValue ?></div>
</td>
		<!-- CheckAmt -->
		<td<?php echo $view_reg_master_netsales->CheckAmt->CellAttributes() ?>>
<div<?php echo $view_reg_master_netsales->CheckAmt->ViewAttributes() ?>><?php echo $view_reg_master_netsales->CheckAmt->ViewValue ?></div>
</td>
		<!-- CreditAmt -->
		<td<?php echo $view_reg_master_netsales->CreditAmt->CellAttributes() ?>>
<div<?php echo $view_reg_master_netsales->CreditAmt->ViewAttributes() ?>><?php echo $view_reg_master_netsales->CreditAmt->ViewValue ?></div>
</td>
	
		<!-- BankCC -->
		<td<?php echo $view_reg_master_netsales->BankCC->CellAttributes() ?>>
<div<?php echo $view_reg_master_netsales->BankCC->ViewAttributes() ?>><?php echo $view_reg_master_netsales->BankCC->ViewValue ?></div>
</td>
		<!-- LunchAmt -->
		<td<?php echo $view_reg_master_netsales->LunchAmt->CellAttributes() ?>>
<div<?php echo $view_reg_master_netsales->LunchAmt->ViewAttributes() ?>><?php echo $view_reg_master_netsales->LunchAmt->ViewValue ?></div>
</td>
		<!-- PayoutAmt -->
		<td<?php echo $view_reg_master_netsales->PayoutAmt->CellAttributes() ?>>
<div<?php echo $view_reg_master_netsales->PayoutAmt->ViewAttributes() ?>><?php echo $view_reg_master_netsales->PayoutAmt->ViewValue ?></div>
</td>
		<!-- 340B -->
		<td<?php echo $view_reg_master_netsales->z340B->CellAttributes() ?>>
<div<?php echo $view_reg_master_netsales->z340B->ViewAttributes() ?>><?php echo $view_reg_master_netsales->z340B->ViewValue ?></div>
</td>
		<!-- R2(CI) -->
		<td<?php echo $view_reg_master_netsales->R228CI29->CellAttributes() ?>>
<div<?php echo $view_reg_master_netsales->R228CI29->ViewAttributes() ?>><?php echo $view_reg_master_netsales->R228CI29->ViewValue ?></div>
</td>
		<!-- Kinray -->
		<td<?php echo $view_reg_master_netsales->Kinray->CellAttributes() ?>>
<div<?php echo $view_reg_master_netsales->Kinray->ViewAttributes() ?>><?php echo $view_reg_master_netsales->Kinray->ViewValue ?></div>
</td>
		<!-- CashAdj -->
		<td<?php echo $view_reg_master_netsales->CashAdj->CellAttributes() ?>>
<div<?php echo $view_reg_master_netsales->CashAdj->ViewAttributes() ?>><?php echo $view_reg_master_netsales->CashAdj->ViewValue ?></div>
</td>
		<!-- OverAmt -->
		<td<?php echo $view_reg_master_netsales->OverAmt->CellAttributes() ?>>
<div<?php echo $view_reg_master_netsales->OverAmt->ViewAttributes() ?>><?php echo $view_reg_master_netsales->OverAmt->ViewValue ?></div>
</td>
<?php if ($view_reg_master_netsales->Export == "") { ?>
<?php } ?>
	</tr>
<?php
	}
	$rs->MoveNext();
}
?>
</table>
<?php if ($view_reg_master_netsales->Export == "") { ?>
<table>
	<tr><td><span class="phpmaker">
	</span></td></tr>
</table>
<?php } ?>
<?php } ?>
</form>
<?php

// Close recordset and connection
if ($rs) $rs->Close();
?>

<?php if (isset($_GET["Refresh"]) || $_GET["Refresh"]==1||$_GET["Refresh"]==0) {
		$sSql = "Call sp_register_master(".$_GET["Refresh"].")";
		$rs = $conn->Execute($sSql);
		//echo $_GET["Refresh"]."===============";
	}
?>

<?php if ($view_reg_master_netsales->Export == "") { ?>
<form action="view_reg_master_netsaleslist.php" name="ewpagerform" id="ewpagerform">
<table border="0" cellspacing="0" cellpadding="0">
	<tr>
		<td nowrap>
<?php if (!isset($Pager)) $Pager = new cPrevNextPager($nStartRec, $nDisplayRecs, $nTotalRecs) ?>
<?php if ($Pager->RecordCount > 0) { ?>
	<table border="0" cellspacing="0" cellpadding="0"><tr><td><span class="phpmaker">Page&nbsp;</span></td>
<!--first page button-->
	<?php if ($Pager->FirstButton->Enabled) { ?>
	<td><a href="view_reg_master_netsaleslist.php?start=<?php echo $Pager->FirstButton->Start ?>"><img src="images/first.gif" alt="First" width="16" height="16" border="0"></a></td>
	<?php } else { ?>
	<td><img src="images/firstdisab.gif" alt="First" width="16" height="16" border="0"></td>
	<?php } ?>
<!--previous page button-->
	<?php if ($Pager->PrevButton->Enabled) { ?>
	<td><a href="view_reg_master_netsaleslist.php?start=<?php echo $Pager->PrevButton->Start ?>"><img src="images/prev.gif" alt="Previous" width="16" height="16" border="0"></a></td>
	<?php } else { ?>
	<td><img src="images/prevdisab.gif" alt="Previous" width="16" height="16" border="0"></td>
	<?php } ?>
<!--current page number-->
	<td><input type="text" name="<?php echo EW_TABLE_PAGE_NO ?>" id="<?php echo EW_TABLE_PAGE_NO ?>" value="<?php echo $Pager->CurrentPage ?>" size="4"></td>
<!--next page button-->
	<?php if ($Pager->NextButton->Enabled) { ?>
	<td><a href="view_reg_master_netsaleslist.php?start=<?php echo $Pager->NextButton->Start ?>"><img src="images/next.gif" alt="Next" width="16" height="16" border="0"></a></td>	
	<?php } else { ?>
	<td><img src="images/nextdisab.gif" alt="Next" width="16" height="16" border="0"></td>
	<?php } ?>
<!--last page button-->
	<?php if ($Pager->LastButton->Enabled) { ?>
	<td><a href="view_reg_master_netsaleslist.php?start=<?php echo $Pager->LastButton->Start ?>"><img src="images/last.gif" alt="Last" width="16" height="16" border="0"></a></td>	
	<?php } else { ?>
	<td><img src="images/lastdisab.gif" alt="Last" width="16" height="16" border="0"></td>
	<?php } ?>
	<td><span class="phpmaker">&nbsp;of <?php echo $Pager->PageCount ?></span></td>
	</tr></table>
	<span class="phpmaker">Records <?php echo $Pager->FromIndex ?> to <?php echo $Pager->ToIndex ?> of <?php echo $Pager->RecordCount ?></span>
<?php } else { ?>
	<?php if ($sSrchWhere == "0=101") { ?>
	<span class="phpmaker">Please enter search criteria</span>
	<?php } else { ?>
	<span class="phpmaker">No records found</span>
	<?php } ?>
<?php } ?>
		</td>
<?php if ($nTotalRecs > 0) { ?>
		<td nowrap>&nbsp;&nbsp;&nbsp;&nbsp;</td>
		<td align="right" valign="top" nowrap><span class="phpmaker">Records Per Page&nbsp;
<select name="<?php echo EW_TABLE_REC_PER_PAGE ?>" id="<?php echo EW_TABLE_REC_PER_PAGE ?>" onChange="this.form.submit();" class="phpmaker">
<option value="20"<?php if ($nDisplayRecs == 20) echo " selected" ?>>20</option>
<option value="ALL"<?php if ($view_reg_master_netsales->getRecordsPerPage() == -1) echo " selected" ?>>All Records</option>
</select>
		</span></td>
<?php } ?>
	</tr>
</table>
</form>
<?php } ?>
<?php if ($view_reg_master_netsales->Export == "") { ?>
<?php } ?>
<?php if ($view_reg_master_netsales->Export == "") { ?>
<script language="JavaScript" type="text/javascript">
<!--

// Write your table-specific startup script here
// document.write("page loaded");
//-->

</script>
<?php } ?>
<?php include "footer.php" ?>
<?php

// If control is passed here, simply terminate the page without redirect
Page_Terminate();

// -----------------------------------------------------------------
//  Subroutine Page_Terminate
//  - called when exit page
//  - clean up connection and objects
//  - if url specified, redirect to url, otherwise end response
function Page_Terminate($url = "") {
	global $conn;

	// Page unload event, used in current page
	Page_Unload();

	// Global page unloaded event (in userfn*.php)
	Page_Unloaded();

	 // Close Connection
	$conn->Close();

	// Go to url if specified
	if ($url <> "") {
		ob_end_clean();
		header("Location: $url");
	}
	exit();
}
?>
<?php

// Set up number of records displayed per page
function SetUpDisplayRecs() {
	global $nDisplayRecs, $nStartRec, $view_reg_master_netsales;
	$sWrk = @$_GET[EW_TABLE_REC_PER_PAGE];
	if ($sWrk <> "") {
		if (is_numeric($sWrk)) {
			$nDisplayRecs = intval($sWrk);
		} else {
			if (strtolower($sWrk) == "all") { // Display all records
				$nDisplayRecs = -1;
			} else {
				$nDisplayRecs = 20; // Non-numeric, load default
			}
		}
		$view_reg_master_netsales->setRecordsPerPage($nDisplayRecs); // Save to Session

		// Reset start position
		$nStartRec = 1;
		$view_reg_master_netsales->setStartRecordNumber($nStartRec);
	} else {
		if ($view_reg_master_netsales->getRecordsPerPage() <> "") {
			$nDisplayRecs = $view_reg_master_netsales->getRecordsPerPage(); // Restore from Session
		} else {
			$nDisplayRecs = 20; // Load default
		}
	}
}

// Return Advanced Search Where based on QueryString parameters
function AdvancedSearchWhere() {
	global $Security, $view_reg_master_netsales;
	$sWhere = "";

	// Field ID
	BuildSearchSql($sWhere, $view_reg_master_netsales->ID, @$_GET["x_ID"], @$_GET["z_ID"], @$_GET["v_ID"], @$_GET["y_ID"], @$_GET["w_ID"]);

	// Field LogDate
	BuildSearchSql($sWhere, $view_reg_master_netsales->LogDate, ew_UnFormatDateTime(@$_GET["x_LogDate"],5), @$_GET["z_LogDate"], @$_GET["v_LogDate"], ew_UnFormatDateTime(@$_GET["y_LogDate"],5), @$_GET["w_LogDate"]);

	// Field RegID
	BuildSearchSql($sWhere, $view_reg_master_netsales->RegID, @$_GET["x_RegID"], @$_GET["z_RegID"], @$_GET["v_RegID"], @$_GET["y_RegID"], @$_GET["w_RegID"]);

	// Field UserName
	BuildSearchSql($sWhere, $view_reg_master_netsales->UserName, @$_GET["x_UserName"], @$_GET["z_UserName"], @$_GET["v_UserName"], @$_GET["y_UserName"], @$_GET["w_UserName"]);

	// Field StoreNet
	BuildSearchSql($sWhere, $view_reg_master_netsales->StoreNet, @$_GET["x_StoreNet"], @$_GET["z_StoreNet"], @$_GET["v_StoreNet"], @$_GET["y_StoreNet"], @$_GET["w_StoreNet"]);

	// Field ShortOver
	BuildSearchSql($sWhere, $view_reg_master_netsales->ShortOver, @$_GET["x_ShortOver"], @$_GET["z_ShortOver"], @$_GET["v_ShortOver"], @$_GET["y_ShortOver"], @$_GET["w_ShortOver"]);

	// Field DiffIPP
	BuildSearchSql($sWhere, $view_reg_master_netsales->DiffIPP, @$_GET["x_DiffIPP"], @$_GET["z_DiffIPP"], @$_GET["v_DiffIPP"], @$_GET["y_DiffIPP"], @$_GET["w_DiffIPP"]);

	// Field LogIPP
	BuildSearchSql($sWhere, $view_reg_master_netsales->LogIPP, @$_GET["x_LogIPP"], @$_GET["z_LogIPP"], @$_GET["v_LogIPP"], @$_GET["y_LogIPP"], @$_GET["w_LogIPP"]);

	// Field BankIPP
	BuildSearchSql($sWhere, $view_reg_master_netsales->BankIPP, @$_GET["x_BankIPP"], @$_GET["z_BankIPP"], @$_GET["v_BankIPP"], @$_GET["y_BankIPP"], @$_GET["w_BankIPP"]);

	// Field DiffXreading
	BuildSearchSql($sWhere, $view_reg_master_netsales->DiffXreading, @$_GET["x_DiffXreading"], @$_GET["z_DiffXreading"], @$_GET["v_DiffXreading"], @$_GET["y_DiffXreading"], @$_GET["w_DiffXreading"]);

	// Field MOAmt
	BuildSearchSql($sWhere, $view_reg_master_netsales->MOAmt, @$_GET["x_MOAmt"], @$_GET["z_MOAmt"], @$_GET["v_MOAmt"], @$_GET["y_MOAmt"], @$_GET["w_MOAmt"]);

	// Field BankMO
	BuildSearchSql($sWhere, $view_reg_master_netsales->BankMO, @$_GET["x_BankMO"], @$_GET["z_BankMO"], @$_GET["v_BankMO"], @$_GET["y_BankMO"], @$_GET["w_BankMO"]);

	// Field BankCC
	BuildSearchSql($sWhere, $view_reg_master_netsales->BankCC, @$_GET["x_BankCC"], @$_GET["z_BankCC"], @$_GET["v_BankCC"], @$_GET["y_BankCC"], @$_GET["w_BankCC"]);

	// Field DiffCopay
	BuildSearchSql($sWhere, $view_reg_master_netsales->DiffCopay, @$_GET["x_DiffCopay"], @$_GET["z_DiffCopay"], @$_GET["v_DiffCopay"], @$_GET["y_DiffCopay"], @$_GET["w_DiffCopay"]);

	// Field CheckAmt
	BuildSearchSql($sWhere, $view_reg_master_netsales->CheckAmt, @$_GET["x_CheckAmt"], @$_GET["z_CheckAmt"], @$_GET["v_CheckAmt"], @$_GET["y_CheckAmt"], @$_GET["w_CheckAmt"]);

	// Field CreditAmt
	BuildSearchSql($sWhere, $view_reg_master_netsales->CreditAmt, @$_GET["x_CreditAmt"], @$_GET["z_CreditAmt"], @$_GET["v_CreditAmt"], @$_GET["y_CreditAmt"], @$_GET["w_CreditAmt"]);

	// Field LunchAmt
	BuildSearchSql($sWhere, $view_reg_master_netsales->LunchAmt, @$_GET["x_LunchAmt"], @$_GET["z_LunchAmt"], @$_GET["v_LunchAmt"], @$_GET["y_LunchAmt"], @$_GET["w_LunchAmt"]);

	// Field PayoutAmt
	BuildSearchSql($sWhere, $view_reg_master_netsales->PayoutAmt, @$_GET["x_PayoutAmt"], @$_GET["z_PayoutAmt"], @$_GET["v_PayoutAmt"], @$_GET["y_PayoutAmt"], @$_GET["w_PayoutAmt"]);

	// Field 340B
	BuildSearchSql($sWhere, $view_reg_master_netsales->z340B, @$_GET["x_z340B"], @$_GET["z_z340B"], @$_GET["v_z340B"], @$_GET["y_z340B"], @$_GET["w_z340B"]);

	// Field R2(CI)
	BuildSearchSql($sWhere, $view_reg_master_netsales->R228CI29, @$_GET["x_R228CI29"], @$_GET["z_R228CI29"], @$_GET["v_R228CI29"], @$_GET["y_R228CI29"], @$_GET["w_R228CI29"]);

	// Field Kinray
	BuildSearchSql($sWhere, $view_reg_master_netsales->Kinray, @$_GET["x_Kinray"], @$_GET["z_Kinray"], @$_GET["v_Kinray"], @$_GET["y_Kinray"], @$_GET["w_Kinray"]);

	// Field CashAdj
	BuildSearchSql($sWhere, $view_reg_master_netsales->CashAdj, @$_GET["x_CashAdj"], @$_GET["z_CashAdj"], @$_GET["v_CashAdj"], @$_GET["y_CashAdj"], @$_GET["w_CashAdj"]);

	// Field OverAmt
	BuildSearchSql($sWhere, $view_reg_master_netsales->OverAmt, @$_GET["x_OverAmt"], @$_GET["z_OverAmt"], @$_GET["v_OverAmt"], @$_GET["y_OverAmt"], @$_GET["w_OverAmt"]);

	//AdvancedSearchWhere = sWhere
	// Set up search parm

	if ($sWhere <> "") {

		// Field ID
		SetSearchParm($view_reg_master_netsales->ID, @$_GET["x_ID"], @$_GET["z_ID"], @$_GET["v_ID"], @$_GET["y_ID"], @$_GET["w_ID"]);

		// Field LogDate
		SetSearchParm($view_reg_master_netsales->LogDate, ew_UnFormatDateTime(@$_GET["x_LogDate"],5), @$_GET["z_LogDate"], @$_GET["v_LogDate"], ew_UnFormatDateTime(@$_GET["y_LogDate"],5), @$_GET["w_LogDate"]);

		// Field RegID
		SetSearchParm($view_reg_master_netsales->RegID, @$_GET["x_RegID"], @$_GET["z_RegID"], @$_GET["v_RegID"], @$_GET["y_RegID"], @$_GET["w_RegID"]);

		// Field UserName
		SetSearchParm($view_reg_master_netsales->UserName, @$_GET["x_UserName"], @$_GET["z_UserName"], @$_GET["v_UserName"], @$_GET["y_UserName"], @$_GET["w_UserName"]);

		// Field StoreNet
		SetSearchParm($view_reg_master_netsales->StoreNet, @$_GET["x_StoreNet"], @$_GET["z_StoreNet"], @$_GET["v_StoreNet"], @$_GET["y_StoreNet"], @$_GET["w_StoreNet"]);

		// Field ShortOver
		SetSearchParm($view_reg_master_netsales->ShortOver, @$_GET["x_ShortOver"], @$_GET["z_ShortOver"], @$_GET["v_ShortOver"], @$_GET["y_ShortOver"], @$_GET["w_ShortOver"]);

		// Field DiffIPP
		SetSearchParm($view_reg_master_netsales->DiffIPP, @$_GET["x_DiffIPP"], @$_GET["z_DiffIPP"], @$_GET["v_DiffIPP"], @$_GET["y_DiffIPP"], @$_GET["w_DiffIPP"]);

		// Field LogIPP
		SetSearchParm($view_reg_master_netsales->LogIPP, @$_GET["x_LogIPP"], @$_GET["z_LogIPP"], @$_GET["v_LogIPP"], @$_GET["y_LogIPP"], @$_GET["w_LogIPP"]);

		// Field BankIPP
		SetSearchParm($view_reg_master_netsales->BankIPP, @$_GET["x_BankIPP"], @$_GET["z_BankIPP"], @$_GET["v_BankIPP"], @$_GET["y_BankIPP"], @$_GET["w_BankIPP"]);

		// Field DiffXreading
		SetSearchParm($view_reg_master_netsales->DiffXreading, @$_GET["x_DiffXreading"], @$_GET["z_DiffXreading"], @$_GET["v_DiffXreading"], @$_GET["y_DiffXreading"], @$_GET["w_DiffXreading"]);

		// Field MOAmt
		SetSearchParm($view_reg_master_netsales->MOAmt, @$_GET["x_MOAmt"], @$_GET["z_MOAmt"], @$_GET["v_MOAmt"], @$_GET["y_MOAmt"], @$_GET["w_MOAmt"]);

		// Field BankMO
		SetSearchParm($view_reg_master_netsales->BankMO, @$_GET["x_BankMO"], @$_GET["z_BankMO"], @$_GET["v_BankMO"], @$_GET["y_BankMO"], @$_GET["w_BankMO"]);

		// Field BankCC
		SetSearchParm($view_reg_master_netsales->BankCC, @$_GET["x_BankCC"], @$_GET["z_BankCC"], @$_GET["v_BankCC"], @$_GET["y_BankCC"], @$_GET["w_BankCC"]);

		// Field DiffCopay
		SetSearchParm($view_reg_master_netsales->DiffCopay, @$_GET["x_DiffCopay"], @$_GET["z_DiffCopay"], @$_GET["v_DiffCopay"], @$_GET["y_DiffCopay"], @$_GET["w_DiffCopay"]);

		// Field CheckAmt
		SetSearchParm($view_reg_master_netsales->CheckAmt, @$_GET["x_CheckAmt"], @$_GET["z_CheckAmt"], @$_GET["v_CheckAmt"], @$_GET["y_CheckAmt"], @$_GET["w_CheckAmt"]);

		// Field CreditAmt
		SetSearchParm($view_reg_master_netsales->CreditAmt, @$_GET["x_CreditAmt"], @$_GET["z_CreditAmt"], @$_GET["v_CreditAmt"], @$_GET["y_CreditAmt"], @$_GET["w_CreditAmt"]);

		// Field LunchAmt
		SetSearchParm($view_reg_master_netsales->LunchAmt, @$_GET["x_LunchAmt"], @$_GET["z_LunchAmt"], @$_GET["v_LunchAmt"], @$_GET["y_LunchAmt"], @$_GET["w_LunchAmt"]);

		// Field PayoutAmt
		SetSearchParm($view_reg_master_netsales->PayoutAmt, @$_GET["x_PayoutAmt"], @$_GET["z_PayoutAmt"], @$_GET["v_PayoutAmt"], @$_GET["y_PayoutAmt"], @$_GET["w_PayoutAmt"]);

		// Field 340B
		SetSearchParm($view_reg_master_netsales->z340B, @$_GET["x_z340B"], @$_GET["z_z340B"], @$_GET["v_z340B"], @$_GET["y_z340B"], @$_GET["w_z340B"]);

		// Field R2(CI)
		SetSearchParm($view_reg_master_netsales->R228CI29, @$_GET["x_R228CI29"], @$_GET["z_R228CI29"], @$_GET["v_R228CI29"], @$_GET["y_R228CI29"], @$_GET["w_R228CI29"]);

		// Field Kinray
		SetSearchParm($view_reg_master_netsales->Kinray, @$_GET["x_Kinray"], @$_GET["z_Kinray"], @$_GET["v_Kinray"], @$_GET["y_Kinray"], @$_GET["w_Kinray"]);

		// Field CashAdj
		SetSearchParm($view_reg_master_netsales->CashAdj, @$_GET["x_CashAdj"], @$_GET["z_CashAdj"], @$_GET["v_CashAdj"], @$_GET["y_CashAdj"], @$_GET["w_CashAdj"]);

		// Field OverAmt
		SetSearchParm($view_reg_master_netsales->OverAmt, @$_GET["x_OverAmt"], @$_GET["z_OverAmt"], @$_GET["v_OverAmt"], @$_GET["y_OverAmt"], @$_GET["w_OverAmt"]);
	}
	return $sWhere;
}

// Build search sql
function BuildSearchSql(&$Where, &$Fld, $FldVal, $FldOpr, $FldCond, $FldVal2, $FldOpr2) {
	$sWrk = "";
	$FldParm = substr($Fld->FldVar, 2);
	$FldVal = ew_StripSlashes($FldVal);
	if (is_array($FldVal)) $FldVal = implode(",", $FldVal);
	$FldVal2 = ew_StripSlashes($FldVal2);
	if (is_array($FldVal2)) $FldVal2 = implode(",", $FldVal2);
	$FldOpr = strtoupper(trim($FldOpr));
	if ($FldOpr == "") $FldOpr = "=";
	$FldOpr2 = strtoupper(trim($FldOpr2));
	if ($FldOpr2 == "") $FldOpr2 = "=";
	if ($Fld->FldDataType == EW_DATATYPE_BOOLEAN) {
		if ($FldVal <> "") $FldVal = ($FldVal == "1") ? $Fld->TrueValue : $Fld->FalseValue;
		if ($FldVal2 <> "") $FldVal2 = ($FldVal2 == "1") ? $Fld->TrueValue : $Fld->FalseValue;
	} elseif ($Fld->FldDataType == EW_DATATYPE_DATE) {
		if ($FldVal <> "") $FldVal = ew_UnFormatDateTime($FldVal, $Fld->FldDateTimeFormat);
		if ($FldVal2 <> "") $FldVal2 = ew_UnFormatDateTime($FldVal2, $Fld->FldDateTimeFormat);
	}
	if ($FldOpr == "BETWEEN") {
		$IsValidValue = (($Fld->FldDataType <> EW_DATATYPE_NUMBER) ||
			($Fld->FldDataType == EW_DATATYPE_NUMBER && is_numeric($FldVal) && is_numeric($FldVal2)));
		if ($FldVal <> "" && $FldVal2 <> "" && $IsValidValue) {
			$sWrk = $Fld->FldExpression . " BETWEEN " . ew_QuotedValue($FldVal, $Fld->FldDataType) .
				" AND " . ew_QuotedValue($FldVal2, $Fld->FldDataType);
		}
	} elseif ($FldOpr == "IS NULL" || $FldOpr == "IS NOT NULL") {
		$sWrk = $Fld->FldExpression . " " . $FldOpr;
	} else {
		$IsValidValue = (($Fld->FldDataType <> EW_DATATYPE_NUMBER) ||
			($Fld->FldDataType == EW_DATATYPE_NUMBER && is_numeric($FldVal)));
		if ($FldVal <> "" && $IsValidValue && ew_IsValidOpr($FldOpr, $Fld->FldDataType)) {
			$sWrk = $Fld->FldExpression . SearchString($FldOpr, $FldVal, $Fld->FldDataType);
		}
		$IsValidValue = (($Fld->FldDataType <> EW_DATATYPE_NUMBER) ||
			($Fld->FldDataType == EW_DATATYPE_NUMBER && is_numeric($FldVal2)));
		if ($FldVal2 <> "" && $IsValidValue && ew_IsValidOpr($FldOpr2, $Fld->FldDataType)) {
			if ($sWrk <> "") {
				$sWrk .= " " . (($FldCond=="OR")?"OR":"AND") . " ";
			}
			$sWrk .= $Fld->FldExpression . SearchString($FldOpr2, $FldVal2, $Fld->FldDataType);
		}
	}
	if ($sWrk <> "") {
		if ($Where <> "") $Where .= " AND ";
		$Where .= "(" . $sWrk . ")";
	}
}

// Return search string
function SearchString($FldOpr, $FldVal, $FldType) {
	if ($FldOpr == "LIKE" || $FldOpr == "NOT LIKE") {
		return " " . $FldOpr . " " . ew_QuotedValue("%" . $FldVal . "%", $FldType);
	} elseif ($FldOpr == "STARTS WITH") {
		return " LIKE " . ew_QuotedValue($FldVal . "%", $FldType);
	} else {
		return " " . $FldOpr . " " . ew_QuotedValue($FldVal, $FldType);
	}
}

// Set search parm
function SetSearchParm($Fld, $FldVal, $FldOpr, $FldCond, $FldVal2, $FldOpr2) {
	global $view_reg_master_netsales;
	$FldParm = substr($Fld->FldVar, 2);
	$FldVal = ew_StripSlashes($FldVal);
	if (is_array($FldVal)) $FldVal = implode(",", $FldVal);
	$FldVal2 = ew_StripSlashes($FldVal2);
	if (is_array($FldVal2)) $FldVal2 = implode(",", $FldVal2);
	$view_reg_master_netsales->setAdvancedSearch("x_" . $FldParm, $FldVal);
	$view_reg_master_netsales->setAdvancedSearch("z_" . $FldParm, $FldOpr);
	$view_reg_master_netsales->setAdvancedSearch("v_" . $FldParm, $FldCond);
	$view_reg_master_netsales->setAdvancedSearch("y_" . $FldParm, $FldVal2);
	$view_reg_master_netsales->setAdvancedSearch("w_" . $FldParm, $FldOpr2);
}

// Return Basic Search sql
function BasicSearchSQL($Keyword) {
	$sKeyword = ew_AdjustSql($Keyword);
	$sql = "";
	$sql .= "`RegID` LIKE '%" . $sKeyword . "%' OR ";
	$sql .= "`UserName` LIKE '%" . $sKeyword . "%' OR ";
	if (substr($sql, -4) == " OR ") $sql = substr($sql, 0, strlen($sql)-4);
	return $sql;
}

// Return Basic Search Where based on search keyword and type
function BasicSearchWhere() {
	global $Security, $view_reg_master_netsales;
	$sSearchStr = "";
	$sSearchKeyword = ew_StripSlashes(@$_GET[EW_TABLE_BASIC_SEARCH]);
	$sSearchType = @$_GET[EW_TABLE_BASIC_SEARCH_TYPE];
	if ($sSearchKeyword <> "") {
		$sSearch = trim($sSearchKeyword);
		if ($sSearchType <> "") {
			while (strpos($sSearch, "  ") !== FALSE)
				$sSearch = str_replace("  ", " ", $sSearch);
			$arKeyword = explode(" ", trim($sSearch));
			foreach ($arKeyword as $sKeyword) {
				if ($sSearchStr <> "") $sSearchStr .= " " . $sSearchType . " ";
				$sSearchStr .= "(" . BasicSearchSQL($sKeyword) . ")";
			}
		} else {
			$sSearchStr = BasicSearchSQL($sSearch);
		}
	}
	if ($sSearchKeyword <> "") {
		$view_reg_master_netsales->setBasicSearchKeyword($sSearchKeyword);
		$view_reg_master_netsales->setBasicSearchType($sSearchType);
	}
	return $sSearchStr;
}

// Clear all search parameters
function ResetSearchParms() {

	// Clear search where
	global $view_reg_master_netsales;
	$sSrchWhere = "";
	$view_reg_master_netsales->setSearchWhere($sSrchWhere);

	// Clear basic search parameters
	ResetBasicSearchParms();

	// Clear advanced search parameters
	ResetAdvancedSearchParms();
}

// Clear all basic search parameters
function ResetBasicSearchParms() {

	// Clear basic search parameters
	global $view_reg_master_netsales;
	$view_reg_master_netsales->setBasicSearchKeyword("");
	$view_reg_master_netsales->setBasicSearchType("");
}

// Clear all advanced search parameters
function ResetAdvancedSearchParms() {

	// Clear advanced search parameters
	global $view_reg_master_netsales;
	$view_reg_master_netsales->setAdvancedSearch("x_ID", "");
	$view_reg_master_netsales->setAdvancedSearch("x_LogDate", "");
	$view_reg_master_netsales->setAdvancedSearch("x_RegID", "");
	$view_reg_master_netsales->setAdvancedSearch("x_UserName", "");
	$view_reg_master_netsales->setAdvancedSearch("x_StoreNet", "");
	$view_reg_master_netsales->setAdvancedSearch("x_ShortOver", "");
	$view_reg_master_netsales->setAdvancedSearch("x_DiffIPP", "");
	$view_reg_master_netsales->setAdvancedSearch("x_LogIPP", "");
	$view_reg_master_netsales->setAdvancedSearch("x_BankIPP", "");
	$view_reg_master_netsales->setAdvancedSearch("x_DiffXreading", "");
	$view_reg_master_netsales->setAdvancedSearch("x_MOAmt", "");
	$view_reg_master_netsales->setAdvancedSearch("x_BankMO", "");
	$view_reg_master_netsales->setAdvancedSearch("x_BankCC", "");
	$view_reg_master_netsales->setAdvancedSearch("x_DiffCopay", "");
	$view_reg_master_netsales->setAdvancedSearch("x_CheckAmt", "");
	$view_reg_master_netsales->setAdvancedSearch("x_CreditAmt", "");
	$view_reg_master_netsales->setAdvancedSearch("x_LunchAmt", "");
	$view_reg_master_netsales->setAdvancedSearch("x_PayoutAmt", "");
	$view_reg_master_netsales->setAdvancedSearch("x_z340B", "");
	$view_reg_master_netsales->setAdvancedSearch("x_R228CI29", "");
	$view_reg_master_netsales->setAdvancedSearch("x_Kinray", "");
	$view_reg_master_netsales->setAdvancedSearch("x_CashAdj", "");
	$view_reg_master_netsales->setAdvancedSearch("x_OverAmt", "");
}

// Restore all search parameters
function RestoreSearchParms() {
	global $sSrchWhere, $view_reg_master_netsales;
	$sSrchWhere = $view_reg_master_netsales->getSearchWhere();

	// Restore advanced search settings
	RestoreAdvancedSearchParms();
}

// Restore all advanced search parameters
function RestoreAdvancedSearchParms() {

	// Restore advanced search parms
	global $view_reg_master_netsales;
	 $view_reg_master_netsales->ID->AdvancedSearch->SearchValue = $view_reg_master_netsales->getAdvancedSearch("x_ID");
	 $view_reg_master_netsales->LogDate->AdvancedSearch->SearchValue = $view_reg_master_netsales->getAdvancedSearch("x_LogDate");
	 $view_reg_master_netsales->RegID->AdvancedSearch->SearchValue = $view_reg_master_netsales->getAdvancedSearch("x_RegID");
	 $view_reg_master_netsales->UserName->AdvancedSearch->SearchValue = $view_reg_master_netsales->getAdvancedSearch("x_UserName");
	 $view_reg_master_netsales->StoreNet->AdvancedSearch->SearchValue = $view_reg_master_netsales->getAdvancedSearch("x_StoreNet");
	 $view_reg_master_netsales->ShortOver->AdvancedSearch->SearchValue = $view_reg_master_netsales->getAdvancedSearch("x_ShortOver");
	 $view_reg_master_netsales->DiffIPP->AdvancedSearch->SearchValue = $view_reg_master_netsales->getAdvancedSearch("x_DiffIPP");
	 $view_reg_master_netsales->LogIPP->AdvancedSearch->SearchValue = $view_reg_master_netsales->getAdvancedSearch("x_LogIPP");
	 $view_reg_master_netsales->BankIPP->AdvancedSearch->SearchValue = $view_reg_master_netsales->getAdvancedSearch("x_BankIPP");
	 $view_reg_master_netsales->DiffXreading->AdvancedSearch->SearchValue = $view_reg_master_netsales->getAdvancedSearch("x_DiffXreading");
	 $view_reg_master_netsales->MOAmt->AdvancedSearch->SearchValue = $view_reg_master_netsales->getAdvancedSearch("x_MOAmt");
	 $view_reg_master_netsales->BankMO->AdvancedSearch->SearchValue = $view_reg_master_netsales->getAdvancedSearch("x_BankMO");
	 $view_reg_master_netsales->BankCC->AdvancedSearch->SearchValue = $view_reg_master_netsales->getAdvancedSearch("x_BankCC");
	 $view_reg_master_netsales->DiffCopay->AdvancedSearch->SearchValue = $view_reg_master_netsales->getAdvancedSearch("x_DiffCopay");
	 $view_reg_master_netsales->CheckAmt->AdvancedSearch->SearchValue = $view_reg_master_netsales->getAdvancedSearch("x_CheckAmt");
	 $view_reg_master_netsales->CreditAmt->AdvancedSearch->SearchValue = $view_reg_master_netsales->getAdvancedSearch("x_CreditAmt");
	 $view_reg_master_netsales->LunchAmt->AdvancedSearch->SearchValue = $view_reg_master_netsales->getAdvancedSearch("x_LunchAmt");
	 $view_reg_master_netsales->PayoutAmt->AdvancedSearch->SearchValue = $view_reg_master_netsales->getAdvancedSearch("x_PayoutAmt");
	 $view_reg_master_netsales->z340B->AdvancedSearch->SearchValue = $view_reg_master_netsales->getAdvancedSearch("x_z340B");
	 $view_reg_master_netsales->R228CI29->AdvancedSearch->SearchValue = $view_reg_master_netsales->getAdvancedSearch("x_R228CI29");
	 $view_reg_master_netsales->Kinray->AdvancedSearch->SearchValue = $view_reg_master_netsales->getAdvancedSearch("x_Kinray");
	 $view_reg_master_netsales->CashAdj->AdvancedSearch->SearchValue = $view_reg_master_netsales->getAdvancedSearch("x_CashAdj");
	 $view_reg_master_netsales->OverAmt->AdvancedSearch->SearchValue = $view_reg_master_netsales->getAdvancedSearch("x_OverAmt");
}

// Set up Sort parameters based on Sort Links clicked
function SetUpSortOrder() {
	global $view_reg_master_netsales;

	// Check for an Order parameter
	if (@$_GET["order"] <> "") {
		$view_reg_master_netsales->CurrentOrder = ew_StripSlashes(@$_GET["order"]);
		$view_reg_master_netsales->CurrentOrderType = @$_GET["ordertype"];

		// Field ID
		$view_reg_master_netsales->UpdateSort($view_reg_master_netsales->ID);

		// Field LogDate
		$view_reg_master_netsales->UpdateSort($view_reg_master_netsales->LogDate);

		// Field RegID
		$view_reg_master_netsales->UpdateSort($view_reg_master_netsales->RegID);

		// Field UserName
		$view_reg_master_netsales->UpdateSort($view_reg_master_netsales->UserName);

		// Field StoreNet
		$view_reg_master_netsales->UpdateSort($view_reg_master_netsales->StoreNet);

		// Field ShortOver
		$view_reg_master_netsales->UpdateSort($view_reg_master_netsales->ShortOver);

		// Field DiffIPP
		$view_reg_master_netsales->UpdateSort($view_reg_master_netsales->DiffIPP);

		// Field LogIPP
		$view_reg_master_netsales->UpdateSort($view_reg_master_netsales->LogIPP);

		// Field BankIPP
		$view_reg_master_netsales->UpdateSort($view_reg_master_netsales->BankIPP);

		// Field DiffXreading
		$view_reg_master_netsales->UpdateSort($view_reg_master_netsales->DiffXreading);

		// Field MOAmt
		$view_reg_master_netsales->UpdateSort($view_reg_master_netsales->MOAmt);

		// Field BankMO
		$view_reg_master_netsales->UpdateSort($view_reg_master_netsales->BankMO);

		// Field BankCC
		$view_reg_master_netsales->UpdateSort($view_reg_master_netsales->BankCC);

		// Field DiffCopay
		$view_reg_master_netsales->UpdateSort($view_reg_master_netsales->DiffCopay);

		// Field CheckAmt
		$view_reg_master_netsales->UpdateSort($view_reg_master_netsales->CheckAmt);

		// Field CreditAmt
		$view_reg_master_netsales->UpdateSort($view_reg_master_netsales->CreditAmt);

		// Field LunchAmt
		$view_reg_master_netsales->UpdateSort($view_reg_master_netsales->LunchAmt);

		// Field PayoutAmt
		$view_reg_master_netsales->UpdateSort($view_reg_master_netsales->PayoutAmt);

		// Field 340B
		$view_reg_master_netsales->UpdateSort($view_reg_master_netsales->z340B);

		// Field R2(CI)
		$view_reg_master_netsales->UpdateSort($view_reg_master_netsales->R228CI29);

		// Field Kinray
		$view_reg_master_netsales->UpdateSort($view_reg_master_netsales->Kinray);

		// Field CashAdj
		$view_reg_master_netsales->UpdateSort($view_reg_master_netsales->CashAdj);

		// Field OverAmt
		$view_reg_master_netsales->UpdateSort($view_reg_master_netsales->OverAmt);
		$view_reg_master_netsales->setStartRecordNumber(1); // Reset start position
	}
	$sOrderBy = $view_reg_master_netsales->getSessionOrderBy(); // Get order by from Session
	if ($sOrderBy == "") {
		if ($view_reg_master_netsales->SqlOrderBy() <> "") {
			$sOrderBy = $view_reg_master_netsales->SqlOrderBy();
			$view_reg_master_netsales->setSessionOrderBy($sOrderBy);
		}
	}
}

// Reset command based on querystring parameter cmd=
// - RESET: reset search parameters
// - RESETALL: reset search & master/detail parameters
// - RESETSORT: reset sort parameters
function ResetCmd() {
	global $sDbMasterFilter, $sDbDetailFilter, $nStartRec, $sOrderBy;
	global $view_reg_master_netsales;

	// Get reset cmd
	if (@$_GET["cmd"] <> "") {
		$sCmd = $_GET["cmd"];

		// Reset search criteria
		if (strtolower($sCmd) == "reset" || strtolower($sCmd) == "resetall") {
			ResetSearchParms();
		}

		// Reset Sort Criteria
		if (strtolower($sCmd) == "resetsort") {
			$sOrderBy = "";
			$view_reg_master_netsales->setSessionOrderBy($sOrderBy);
			$view_reg_master_netsales->ID->setSort("");
			$view_reg_master_netsales->LogDate->setSort("");
			$view_reg_master_netsales->RegID->setSort("");
			$view_reg_master_netsales->UserName->setSort("");
			$view_reg_master_netsales->StoreNet->setSort("");
			$view_reg_master_netsales->ShortOver->setSort("");
			$view_reg_master_netsales->DiffIPP->setSort("");
			$view_reg_master_netsales->LogIPP->setSort("");
			$view_reg_master_netsales->BankIPP->setSort("");
			$view_reg_master_netsales->DiffXreading->setSort("");
			$view_reg_master_netsales->MOAmt->setSort("");
			$view_reg_master_netsales->BankMO->setSort("");
			$view_reg_master_netsales->BankCC->setSort("");
			$view_reg_master_netsales->DiffCopay->setSort("");
			$view_reg_master_netsales->CheckAmt->setSort("");
			$view_reg_master_netsales->CreditAmt->setSort("");
			$view_reg_master_netsales->LunchAmt->setSort("");
			$view_reg_master_netsales->PayoutAmt->setSort("");
			$view_reg_master_netsales->z340B->setSort("");
			$view_reg_master_netsales->R228CI29->setSort("");
			$view_reg_master_netsales->Kinray->setSort("");
			$view_reg_master_netsales->CashAdj->setSort("");
			$view_reg_master_netsales->OverAmt->setSort("");
		}

		// Reset start position
		$nStartRec = 1;
		$view_reg_master_netsales->setStartRecordNumber($nStartRec);
	}
}
?>
<?php

// Set up Starting Record parameters based on Pager Navigation
function SetUpStartRec() {
	global $nDisplayRecs, $nStartRec, $nTotalRecs, $nPageNo, $view_reg_master_netsales;
	if ($nDisplayRecs == 0) return;

	// Check for a START parameter
	if (@$_GET[EW_TABLE_START_REC] <> "") {
		$nStartRec = $_GET[EW_TABLE_START_REC];
		$view_reg_master_netsales->setStartRecordNumber($nStartRec);
	} elseif (@$_GET[EW_TABLE_PAGE_NO] <> "") {
		$nPageNo = $_GET[EW_TABLE_PAGE_NO];
		if (is_numeric($nPageNo)) {
			$nStartRec = ($nPageNo-1)*$nDisplayRecs+1;
			if ($nStartRec <= 0) {
				$nStartRec = 1;
			} elseif ($nStartRec >= intval(($nTotalRecs-1)/$nDisplayRecs)*$nDisplayRecs+1) {
				$nStartRec = intval(($nTotalRecs-1)/$nDisplayRecs)*$nDisplayRecs+1;
			}
			$view_reg_master_netsales->setStartRecordNumber($nStartRec);
		} else {
			$nStartRec = $view_reg_master_netsales->getStartRecordNumber();
		}
	} else {
		$nStartRec = $view_reg_master_netsales->getStartRecordNumber();
	}

	// Check if correct start record counter
	if (!is_numeric($nStartRec) || $nStartRec == "") { // Avoid invalid start record counter
		$nStartRec = 1; // Reset start record counter
		$view_reg_master_netsales->setStartRecordNumber($nStartRec);
	} elseif (intval($nStartRec) > intval($nTotalRecs)) { // Avoid starting record > total records
		$nStartRec = intval(($nTotalRecs-1)/$nDisplayRecs)*$nDisplayRecs+1; // Point to last page first record
		$view_reg_master_netsales->setStartRecordNumber($nStartRec);
	} elseif (($nStartRec-1) % $nDisplayRecs <> 0) {
		$nStartRec = intval(($nStartRec-1)/$nDisplayRecs)*$nDisplayRecs+1; // Point to page boundary
		$view_reg_master_netsales->setStartRecordNumber($nStartRec);
	}
}
?>
<?php

// Load recordset
function LoadRecordset($offset = -1, $rowcnt = -1) {
	global $conn, $view_reg_master_netsales;

	// Call Recordset Selecting event
	$view_reg_master_netsales->Recordset_Selecting($view_reg_master_netsales->CurrentFilter);

	// Load list page sql
	$sSql = $view_reg_master_netsales->SelectSQL();
	if ($offset > -1 && $rowcnt > -1) $sSql .= " LIMIT $offset, $rowcnt";

	// Load recordset
	$conn->raiseErrorFn = 'ew_ErrorFn';	
	$rs = $conn->Execute($sSql);
	$conn->raiseErrorFn = '';

	// Call Recordset Selected event
	$view_reg_master_netsales->Recordset_Selected($rs);
	return $rs;
}
?>
<?php

// Load row based on key values
function LoadRow() {
	global $conn, $Security, $view_reg_master_netsales;
	$sFilter = $view_reg_master_netsales->SqlKeyFilter();
	if (!is_numeric($view_reg_master_netsales->ID->CurrentValue)) {
		return FALSE; // Invalid key, exit
	}
	$sFilter = str_replace("@ID@", ew_AdjustSql($view_reg_master_netsales->ID->CurrentValue), $sFilter); // Replace key value

	// Call Row Selecting event
	$view_reg_master_netsales->Row_Selecting($sFilter);

	// Load sql based on filter
	$view_reg_master_netsales->CurrentFilter = $sFilter;
	$sSql = $view_reg_master_netsales->SQL();
	if ($rs = $conn->Execute($sSql)) {
		if ($rs->EOF) {
			$LoadRow = FALSE;
		} else {
			$LoadRow = TRUE;
			$rs->MoveFirst();
			LoadRowValues($rs); // Load row values

			// Call Row Selected event
			$view_reg_master_netsales->Row_Selected($rs);
		}
		$rs->Close();
	} else {
		$LoadRow = FALSE;
	}
	return $LoadRow;
}

// Load row values from recordset
function LoadRowValues(&$rs) {
	global $view_reg_master_netsales;
	$view_reg_master_netsales->ID->setDbValue($rs->fields('ID'));
	$view_reg_master_netsales->LogDate->setDbValue($rs->fields('LogDate'));
	$view_reg_master_netsales->RegID->setDbValue($rs->fields('RegID'));
	$view_reg_master_netsales->UserName->setDbValue($rs->fields('UserName'));
	$view_reg_master_netsales->StoreNet->setDbValue($rs->fields('StoreNet'));
	$view_reg_master_netsales->ShortOver->setDbValue($rs->fields('ShortOver'));
	$view_reg_master_netsales->DiffIPP->setDbValue($rs->fields('DiffIPP'));
	$view_reg_master_netsales->LogIPP->setDbValue($rs->fields('LogIPP'));
	$view_reg_master_netsales->BankIPP->setDbValue($rs->fields('BankIPP'));
	$view_reg_master_netsales->DiffXreading->setDbValue($rs->fields('DiffXreading'));
	$view_reg_master_netsales->MOAmt->setDbValue($rs->fields('MOAmt'));
	$view_reg_master_netsales->BankMO->setDbValue($rs->fields('BankMO'));
	$view_reg_master_netsales->BankCC->setDbValue($rs->fields('BankCC'));
	$view_reg_master_netsales->DiffCopay->setDbValue($rs->fields('DiffCopay'));
	$view_reg_master_netsales->CheckAmt->setDbValue($rs->fields('CheckAmt'));
	$view_reg_master_netsales->CreditAmt->setDbValue($rs->fields('CreditAmt'));
	$view_reg_master_netsales->LunchAmt->setDbValue($rs->fields('LunchAmt'));
	$view_reg_master_netsales->PayoutAmt->setDbValue($rs->fields('PayoutAmt'));
	$view_reg_master_netsales->z340B->setDbValue($rs->fields('340B'));
	$view_reg_master_netsales->R228CI29->setDbValue($rs->fields('R2(CI)'));
	$view_reg_master_netsales->Kinray->setDbValue($rs->fields('Kinray'));
	$view_reg_master_netsales->CashAdj->setDbValue($rs->fields('CashAdj'));
	$view_reg_master_netsales->OverAmt->setDbValue($rs->fields('OverAmt'));
}
?>
<?php

// Render row values based on field settings
function RenderRow() {
	global $conn, $Security, $view_reg_master_netsales;

	// Call Row Rendering event
	$view_reg_master_netsales->Row_Rendering();

	// Common render codes for all row types
	// ID

	$view_reg_master_netsales->ID->CellCssStyle = "white-space: nowrap;";
	$view_reg_master_netsales->ID->CellCssClass = "";

	// LogDate
	$view_reg_master_netsales->LogDate->CellCssStyle = "white-space: nowrap;";
	$view_reg_master_netsales->LogDate->CellCssClass = "";

	// RegID
	$view_reg_master_netsales->RegID->CellCssStyle = "white-space: nowrap;";
	$view_reg_master_netsales->RegID->CellCssClass = "";

	// UserName
	$view_reg_master_netsales->UserName->CellCssStyle = "white-space: nowrap;";
	$view_reg_master_netsales->UserName->CellCssClass = "";

	// StoreNet
	$view_reg_master_netsales->StoreNet->CellCssStyle = "white-space: nowrap;";
	$view_reg_master_netsales->StoreNet->CellCssClass = "";

	// ShortOver
	$view_reg_master_netsales->ShortOver->CellCssStyle = "white-space: nowrap;";
	$view_reg_master_netsales->ShortOver->CellCssClass = "";

	// DiffIPP
	$view_reg_master_netsales->DiffIPP->CellCssStyle = "white-space: nowrap;";
	$view_reg_master_netsales->DiffIPP->CellCssClass = "";

	// LogIPP
	$view_reg_master_netsales->LogIPP->CellCssStyle = "white-space: nowrap;";
	$view_reg_master_netsales->LogIPP->CellCssClass = "";

	// BankIPP
	$view_reg_master_netsales->BankIPP->CellCssStyle = "";
	$view_reg_master_netsales->BankIPP->CellCssClass = "";

	// DiffXreading
	$view_reg_master_netsales->DiffXreading->CellCssStyle = "white-space: nowrap;";
	$view_reg_master_netsales->DiffXreading->CellCssClass = "";

	// MOAmt
	$view_reg_master_netsales->MOAmt->CellCssStyle = "white-space: nowrap;";
	$view_reg_master_netsales->MOAmt->CellCssClass = "";

	// BankMO
	$view_reg_master_netsales->BankMO->CellCssStyle = "";
	$view_reg_master_netsales->BankMO->CellCssClass = "";

	// BankCC
	$view_reg_master_netsales->BankCC->CellCssStyle = "";
	$view_reg_master_netsales->BankCC->CellCssClass = "";

	// DiffCopay
	$view_reg_master_netsales->DiffCopay->CellCssStyle = "";
	$view_reg_master_netsales->DiffCopay->CellCssClass = "";

	// CheckAmt
	$view_reg_master_netsales->CheckAmt->CellCssStyle = "white-space: nowrap;";
	$view_reg_master_netsales->CheckAmt->CellCssClass = "";

	// CreditAmt
	$view_reg_master_netsales->CreditAmt->CellCssStyle = "white-space: nowrap;";
	$view_reg_master_netsales->CreditAmt->CellCssClass = "";

	// LunchAmt
	$view_reg_master_netsales->LunchAmt->CellCssStyle = "white-space: nowrap;";
	$view_reg_master_netsales->LunchAmt->CellCssClass = "";

	// PayoutAmt
	$view_reg_master_netsales->PayoutAmt->CellCssStyle = "white-space: nowrap;";
	$view_reg_master_netsales->PayoutAmt->CellCssClass = "";

	// 340B
	$view_reg_master_netsales->z340B->CellCssStyle = "white-space: nowrap;";
	$view_reg_master_netsales->z340B->CellCssClass = "";

	// R2(CI)
	$view_reg_master_netsales->R228CI29->CellCssStyle = "white-space: nowrap;";
	$view_reg_master_netsales->R228CI29->CellCssClass = "";

	// Kinray
	$view_reg_master_netsales->Kinray->CellCssStyle = "white-space: nowrap;";
	$view_reg_master_netsales->Kinray->CellCssClass = "";

	// CashAdj
	$view_reg_master_netsales->CashAdj->CellCssStyle = "white-space: nowrap;";
	$view_reg_master_netsales->CashAdj->CellCssClass = "";

	// OverAmt
	$view_reg_master_netsales->OverAmt->CellCssStyle = "white-space: nowrap;";
	$view_reg_master_netsales->OverAmt->CellCssClass = "";
	if ($view_reg_master_netsales->RowType == EW_ROWTYPE_VIEW) { // View row

		// ID
		$view_reg_master_netsales->ID->ViewValue = $view_reg_master_netsales->ID->CurrentValue;
		$view_reg_master_netsales->ID->CssStyle = "";
		$view_reg_master_netsales->ID->CssClass = "";
		$view_reg_master_netsales->ID->ViewCustomAttributes = "";

		// LogDate
		$view_reg_master_netsales->LogDate->ViewValue = $view_reg_master_netsales->LogDate->CurrentValue;
		$view_reg_master_netsales->LogDate->ViewValue = ew_FormatDateTime($view_reg_master_netsales->LogDate->ViewValue, 5);
		$view_reg_master_netsales->LogDate->CssStyle = "";
		$view_reg_master_netsales->LogDate->CssClass = "";
		$view_reg_master_netsales->LogDate->ViewCustomAttributes = "";

		// RegID
		if (!is_null($view_reg_master_netsales->RegID->CurrentValue)) {
			$sSqlWrk = "SELECT `RegisterID` FROM `tb_register` WHERE `RegisterID` = '" . ew_AdjustSql($view_reg_master_netsales->RegID->CurrentValue) . "'";
			$sSqlWrk .= " ORDER BY `RegisterID` Asc";
			$rswrk = $conn->Execute($sSqlWrk);
			if ($rswrk) {
				if (!$rswrk->EOF) {
					$view_reg_master_netsales->RegID->ViewValue = $rswrk->fields('RegisterID');
				}
				$rswrk->Close();
			} else {
				$view_reg_master_netsales->RegID->ViewValue = $view_reg_master_netsales->RegID->CurrentValue;
			}
		} else {
			$view_reg_master_netsales->RegID->ViewValue = NULL;
		}
		$view_reg_master_netsales->RegID->CssStyle = "";
		$view_reg_master_netsales->RegID->CssClass = "";
		$view_reg_master_netsales->RegID->ViewCustomAttributes = "";

		// UserName
		$view_reg_master_netsales->UserName->ViewValue = $view_reg_master_netsales->UserName->CurrentValue;
		$view_reg_master_netsales->UserName->CssStyle = "";
		$view_reg_master_netsales->UserName->CssClass = "";
		$view_reg_master_netsales->UserName->ViewCustomAttributes = "";

		// StoreNet
		$view_reg_master_netsales->StoreNet->ViewValue = $view_reg_master_netsales->StoreNet->CurrentValue;
		$view_reg_master_netsales->StoreNet->ViewValue = ew_FormatNumber($view_reg_master_netsales->StoreNet->ViewValue, 2, -2, -2, -2);
		$view_reg_master_netsales->StoreNet->CssStyle = "";
		$view_reg_master_netsales->StoreNet->CssClass = "";
		$view_reg_master_netsales->StoreNet->ViewCustomAttributes = "";

		// ShortOver
		$view_reg_master_netsales->ShortOver->ViewValue = $view_reg_master_netsales->ShortOver->CurrentValue;
		$view_reg_master_netsales->ShortOver->ViewValue = ew_FormatNumber($view_reg_master_netsales->ShortOver->ViewValue, 2, -2, -2, -2);
		$view_reg_master_netsales->ShortOver->CssStyle = "";
		$view_reg_master_netsales->ShortOver->CssClass = "";
		$view_reg_master_netsales->ShortOver->ViewCustomAttributes = "";

		// DiffIPP
		$view_reg_master_netsales->DiffIPP->ViewValue = $view_reg_master_netsales->DiffIPP->CurrentValue;
		$view_reg_master_netsales->DiffIPP->ViewValue = ew_FormatNumber($view_reg_master_netsales->DiffIPP->ViewValue, 2, -2, -2, -2);
		$view_reg_master_netsales->DiffIPP->CssStyle = "";
		$view_reg_master_netsales->DiffIPP->CssClass = "";
		$view_reg_master_netsales->DiffIPP->ViewCustomAttributes = "";

		// LogIPP
		$view_reg_master_netsales->LogIPP->ViewValue = $view_reg_master_netsales->LogIPP->CurrentValue;
		$view_reg_master_netsales->LogIPP->ViewValue = ew_FormatNumber($view_reg_master_netsales->LogIPP->ViewValue, 2, -2, -2, -2);
		$view_reg_master_netsales->LogIPP->CssStyle = "";
		$view_reg_master_netsales->LogIPP->CssClass = "";
		$view_reg_master_netsales->LogIPP->ViewCustomAttributes = "";

		// BankIPP
		$view_reg_master_netsales->BankIPP->ViewValue = $view_reg_master_netsales->BankIPP->CurrentValue;
		$view_reg_master_netsales->BankIPP->ViewValue = ew_FormatCurrency($view_reg_master_netsales->BankIPP->ViewValue, 2, -2, -2, -2);
		$view_reg_master_netsales->BankIPP->CssStyle = "";
		$view_reg_master_netsales->BankIPP->CssClass = "";
		$view_reg_master_netsales->BankIPP->ViewCustomAttributes = "";

		// DiffXreading
		$view_reg_master_netsales->DiffXreading->ViewValue = $view_reg_master_netsales->DiffXreading->CurrentValue;
		$view_reg_master_netsales->DiffXreading->ViewValue = ew_FormatNumber($view_reg_master_netsales->DiffXreading->ViewValue, 2, -2, -2, -2);
		$view_reg_master_netsales->DiffXreading->CssStyle = "";
		$view_reg_master_netsales->DiffXreading->CssClass = "";
		$view_reg_master_netsales->DiffXreading->ViewCustomAttributes = "";

		// MOAmt
		$view_reg_master_netsales->MOAmt->ViewValue = $view_reg_master_netsales->MOAmt->CurrentValue;
		$view_reg_master_netsales->MOAmt->ViewValue = ew_FormatNumber($view_reg_master_netsales->MOAmt->ViewValue, 2, -2, -2, -2);
		$view_reg_master_netsales->MOAmt->CssStyle = "";
		$view_reg_master_netsales->MOAmt->CssClass = "";
		$view_reg_master_netsales->MOAmt->ViewCustomAttributes = "";

		// BankMO
		$view_reg_master_netsales->BankMO->ViewValue = $view_reg_master_netsales->BankMO->CurrentValue;
		$view_reg_master_netsales->BankMO->ViewValue = ew_FormatNumber($view_reg_master_netsales->BankMO->ViewValue, 2, -2, -2, -2);
		$view_reg_master_netsales->BankMO->CssStyle = "";
		$view_reg_master_netsales->BankMO->CssClass = "";
		$view_reg_master_netsales->BankMO->ViewCustomAttributes = "";

		// BankCC
		$view_reg_master_netsales->BankCC->ViewValue = $view_reg_master_netsales->BankCC->CurrentValue;
		$view_reg_master_netsales->BankCC->ViewValue = ew_FormatNumber($view_reg_master_netsales->BankCC->ViewValue, 2, -1, -2, -2);
		$view_reg_master_netsales->BankCC->CssStyle = "";
		$view_reg_master_netsales->BankCC->CssClass = "";
		$view_reg_master_netsales->BankCC->ViewCustomAttributes = "";

		// DiffCopay
		$view_reg_master_netsales->DiffCopay->ViewValue = $view_reg_master_netsales->DiffCopay->CurrentValue;
		$view_reg_master_netsales->DiffCopay->ViewValue = ew_FormatNumber($view_reg_master_netsales->DiffCopay->ViewValue, 2, -1, -2, -2);
		$view_reg_master_netsales->DiffCopay->CssStyle = "";
		$view_reg_master_netsales->DiffCopay->CssClass = "";
		$view_reg_master_netsales->DiffCopay->ViewCustomAttributes = "";

		// CheckAmt
		$view_reg_master_netsales->CheckAmt->ViewValue = $view_reg_master_netsales->CheckAmt->CurrentValue;
		$view_reg_master_netsales->CheckAmt->ViewValue = ew_FormatNumber($view_reg_master_netsales->CheckAmt->ViewValue, 2, -2, -2, -2);
		$view_reg_master_netsales->CheckAmt->CssStyle = "";
		$view_reg_master_netsales->CheckAmt->CssClass = "";
		$view_reg_master_netsales->CheckAmt->ViewCustomAttributes = "";

		// CreditAmt
		$view_reg_master_netsales->CreditAmt->ViewValue = $view_reg_master_netsales->CreditAmt->CurrentValue;
		$view_reg_master_netsales->CreditAmt->ViewValue = ew_FormatNumber($view_reg_master_netsales->CreditAmt->ViewValue, 2, -2, -2, -2);
		$view_reg_master_netsales->CreditAmt->CssStyle = "";
		$view_reg_master_netsales->CreditAmt->CssClass = "";
		$view_reg_master_netsales->CreditAmt->ViewCustomAttributes = "";

		// LunchAmt
		$view_reg_master_netsales->LunchAmt->ViewValue = $view_reg_master_netsales->LunchAmt->CurrentValue;
		$view_reg_master_netsales->LunchAmt->ViewValue = ew_FormatNumber($view_reg_master_netsales->LunchAmt->ViewValue, 2, -2, -2, -2);
		$view_reg_master_netsales->LunchAmt->CssStyle = "";
		$view_reg_master_netsales->LunchAmt->CssClass = "";
		$view_reg_master_netsales->LunchAmt->ViewCustomAttributes = "";

		// PayoutAmt
		$view_reg_master_netsales->PayoutAmt->ViewValue = $view_reg_master_netsales->PayoutAmt->CurrentValue;
		$view_reg_master_netsales->PayoutAmt->ViewValue = ew_FormatNumber($view_reg_master_netsales->PayoutAmt->ViewValue, 2, -2, -2, -2);
		$view_reg_master_netsales->PayoutAmt->CssStyle = "";
		$view_reg_master_netsales->PayoutAmt->CssClass = "";
		$view_reg_master_netsales->PayoutAmt->ViewCustomAttributes = "";

		// 340B
		$view_reg_master_netsales->z340B->ViewValue = $view_reg_master_netsales->z340B->CurrentValue;
		$view_reg_master_netsales->z340B->ViewValue = ew_FormatNumber($view_reg_master_netsales->z340B->ViewValue, 2, -2, -2, -2);
		$view_reg_master_netsales->z340B->CssStyle = "";
		$view_reg_master_netsales->z340B->CssClass = "";
		$view_reg_master_netsales->z340B->ViewCustomAttributes = "";

		// R2(CI)
		$view_reg_master_netsales->R228CI29->ViewValue = $view_reg_master_netsales->R228CI29->CurrentValue;
		$view_reg_master_netsales->R228CI29->ViewValue = ew_FormatNumber($view_reg_master_netsales->R228CI29->ViewValue, 2, -2, -2, -2);
		$view_reg_master_netsales->R228CI29->CssStyle = "";
		$view_reg_master_netsales->R228CI29->CssClass = "";
		$view_reg_master_netsales->R228CI29->ViewCustomAttributes = "";

		// Kinray
		$view_reg_master_netsales->Kinray->ViewValue = $view_reg_master_netsales->Kinray->CurrentValue;
		$view_reg_master_netsales->Kinray->ViewValue = ew_FormatNumber($view_reg_master_netsales->Kinray->ViewValue, 2, -2, -2, -2);
		$view_reg_master_netsales->Kinray->CssStyle = "";
		$view_reg_master_netsales->Kinray->CssClass = "";
		$view_reg_master_netsales->Kinray->ViewCustomAttributes = "";

		// CashAdj
		$view_reg_master_netsales->CashAdj->ViewValue = $view_reg_master_netsales->CashAdj->CurrentValue;
		$view_reg_master_netsales->CashAdj->ViewValue = ew_FormatNumber($view_reg_master_netsales->CashAdj->ViewValue, 2, -2, -2, -2);
		$view_reg_master_netsales->CashAdj->CssStyle = "";
		$view_reg_master_netsales->CashAdj->CssClass = "";
		$view_reg_master_netsales->CashAdj->ViewCustomAttributes = "";

		// OverAmt
		$view_reg_master_netsales->OverAmt->ViewValue = $view_reg_master_netsales->OverAmt->CurrentValue;
		$view_reg_master_netsales->OverAmt->ViewValue = ew_FormatNumber($view_reg_master_netsales->OverAmt->ViewValue, 2, -2, -2, -2);
		$view_reg_master_netsales->OverAmt->CssStyle = "";
		$view_reg_master_netsales->OverAmt->CssClass = "";
		$view_reg_master_netsales->OverAmt->ViewCustomAttributes = "";

		// ID
		$view_reg_master_netsales->ID->HrefValue = "";

		// LogDate
		$view_reg_master_netsales->LogDate->HrefValue = "";

		// RegID
		$view_reg_master_netsales->RegID->HrefValue = "";

		// UserName
		$view_reg_master_netsales->UserName->HrefValue = "";

		// StoreNet
		$view_reg_master_netsales->StoreNet->HrefValue = "";

		// ShortOver
		$view_reg_master_netsales->ShortOver->HrefValue = "";

		// DiffIPP
		$view_reg_master_netsales->DiffIPP->HrefValue = "";

		// LogIPP
		$view_reg_master_netsales->LogIPP->HrefValue = "";

		// BankIPP
		$view_reg_master_netsales->BankIPP->HrefValue = "";

		// DiffXreading
		$view_reg_master_netsales->DiffXreading->HrefValue = "";

		// MOAmt
		$view_reg_master_netsales->MOAmt->HrefValue = "";

		// BankMO
		$view_reg_master_netsales->BankMO->HrefValue = "";

		// BankCC
		$view_reg_master_netsales->BankCC->HrefValue = "";

		// DiffCopay
		$view_reg_master_netsales->DiffCopay->HrefValue = "";

		// CheckAmt
		$view_reg_master_netsales->CheckAmt->HrefValue = "";

		// CreditAmt
		$view_reg_master_netsales->CreditAmt->HrefValue = "";

		// LunchAmt
		$view_reg_master_netsales->LunchAmt->HrefValue = "";

		// PayoutAmt
		$view_reg_master_netsales->PayoutAmt->HrefValue = "";

		// 340B
		$view_reg_master_netsales->z340B->HrefValue = "";

		// R2(CI)
		$view_reg_master_netsales->R228CI29->HrefValue = "";

		// Kinray
		$view_reg_master_netsales->Kinray->HrefValue = "";

		// CashAdj
		$view_reg_master_netsales->CashAdj->HrefValue = "";

		// OverAmt
		$view_reg_master_netsales->OverAmt->HrefValue = "";
	} elseif ($view_reg_master_netsales->RowType == EW_ROWTYPE_ADD) { // Add row
	} elseif ($view_reg_master_netsales->RowType == EW_ROWTYPE_EDIT) { // Edit row
	} elseif ($view_reg_master_netsales->RowType == EW_ROWTYPE_SEARCH) { // Search row

		// LogDate
		$view_reg_master_netsales->LogDate->EditCustomAttributes = "";
		$view_reg_master_netsales->LogDate->EditValue = ew_HtmlEncode(ew_FormatDateTime($view_reg_master_netsales->LogDate->AdvancedSearch->SearchValue, 5));

		// RegID
		$view_reg_master_netsales->RegID->EditCustomAttributes = "";
		$sSqlWrk = "SELECT `RegisterID`, `RegisterID` FROM `tb_register`";
		$sSqlWrk .= " ORDER BY `RegisterID` Asc";
		$rswrk = $conn->Execute($sSqlWrk);
		$arwrk = ($rswrk) ? $rswrk->GetRows() : array();
		if ($rswrk) $rswrk->Close();
		array_unshift($arwrk, array("", "Please Select"));
		$view_reg_master_netsales->RegID->EditValue = $arwrk;
	}

	// Call Row Rendered event
	$view_reg_master_netsales->Row_Rendered();
}
?>
<?php

// Load advanced search
function LoadAdvancedSearch() {
	global $view_reg_master_netsales;
	$view_reg_master_netsales->LogDate->AdvancedSearch->SearchValue = $view_reg_master_netsales->getAdvancedSearch("x_LogDate");
	$view_reg_master_netsales->RegID->AdvancedSearch->SearchValue = $view_reg_master_netsales->getAdvancedSearch("x_RegID");
}
?>
<?php

// Export data in Xml or Csv format
function ExportData() {
	global $nTotalRecs, $nStartRec, $nStopRec, $nTotalRecs, $nDisplayRecs, $view_reg_master_netsales;
	$sCsvStr = "";
	$rs = LoadRecordset();
	$nTotalRecs = $rs->RecordCount();
	$nStartRec = 1;

	// Export all
	if (defined("EW_EXPORT_ALL")) {
		$nStopRec = $nTotalRecs;
	} else { // Export 1 page only
		SetUpStartRec(); // Set Up Start Record Position

		// Set the last record to display
		if ($nDisplayRecs < 0) {
			$nStopRec = $nTotalRecs;
		} else {
			$nStopRec = $nStartRec + $nDisplayRecs - 1;
		}
	}
	if ($view_reg_master_netsales->Export == "csv") {
		$sCsvStr .= "ID" . ",";
		$sCsvStr .= "LogDate" . ",";
		$sCsvStr .= "RegID" . ",";
		$sCsvStr .= "UserName" . ",";
		$sCsvStr .= "StoreNet" . ",";
		$sCsvStr .= "ShortOver" . ",";
		$sCsvStr .= "DiffIPP" . ",";
		$sCsvStr .= "LogIPP" . ",";
		$sCsvStr .= "BankIPP" . ",";
		$sCsvStr .= "DiffXreading" . ",";
		$sCsvStr .= "MOAmt" . ",";
		$sCsvStr .= "BankMO" . ",";
		$sCsvStr .= "BankCC" . ",";
		$sCsvStr .= "DiffCopay" . ",";
		$sCsvStr .= "CheckAmt" . ",";
		$sCsvStr .= "CreditAmt" . ",";
		$sCsvStr .= "LunchAmt" . ",";
		$sCsvStr .= "PayoutAmt" . ",";
		$sCsvStr .= "340B" . ",";
		$sCsvStr .= "R2(CI)" . ",";
		$sCsvStr .= "Kinray" . ",";
		$sCsvStr .= "CashAdj" . ",";
		$sCsvStr .= "OverAmt" . ",";
		$sCsvStr = substr($sCsvStr, 0, strlen($sCsvStr)-1); // Remove last comma
		$sCsvStr .= "\n";
	}

	// Move to first record directly for performance reason
	$nRecCount = $nStartRec - 1;
	if (!$rs->EOF) {
		$rs->MoveFirst();
		$rs->Move($nStartRec - 1);
	}
	while (!$rs->EOF && $nRecCount < $nStopRec) {
		$nRecCount++;
		if (intval($nRecCount) >= intval($nStartRec)) {
			LoadRowValues($rs);
			if ($view_reg_master_netsales->Export == "csv") {
				$sCsvStr .= '"' . str_replace('"', '""', strval($view_reg_master_netsales->ID->CurrentValue)) . '",';
				$sCsvStr .= '"' . str_replace('"', '""', strval($view_reg_master_netsales->LogDate->CurrentValue)) . '",';
				$sCsvStr .= '"' . str_replace('"', '""', strval($view_reg_master_netsales->RegID->CurrentValue)) . '",';
				$sCsvStr .= '"' . str_replace('"', '""', strval($view_reg_master_netsales->UserName->CurrentValue)) . '",';
				$sCsvStr .= '"' . str_replace('"', '""', strval($view_reg_master_netsales->StoreNet->CurrentValue)) . '",';
				$sCsvStr .= '"' . str_replace('"', '""', strval($view_reg_master_netsales->ShortOver->CurrentValue)) . '",';
				$sCsvStr .= '"' . str_replace('"', '""', strval($view_reg_master_netsales->DiffIPP->CurrentValue)) . '",';
				$sCsvStr .= '"' . str_replace('"', '""', strval($view_reg_master_netsales->LogIPP->CurrentValue)) . '",';
				$sCsvStr .= '"' . str_replace('"', '""', strval($view_reg_master_netsales->BankIPP->CurrentValue)) . '",';
				$sCsvStr .= '"' . str_replace('"', '""', strval($view_reg_master_netsales->DiffXreading->CurrentValue)) . '",';
				$sCsvStr .= '"' . str_replace('"', '""', strval($view_reg_master_netsales->MOAmt->CurrentValue)) . '",';
				$sCsvStr .= '"' . str_replace('"', '""', strval($view_reg_master_netsales->BankMO->CurrentValue)) . '",';
				$sCsvStr .= '"' . str_replace('"', '""', strval($view_reg_master_netsales->BankCC->CurrentValue)) . '",';
				$sCsvStr .= '"' . str_replace('"', '""', strval($view_reg_master_netsales->DiffCopay->CurrentValue)) . '",';
				$sCsvStr .= '"' . str_replace('"', '""', strval($view_reg_master_netsales->CheckAmt->CurrentValue)) . '",';
				$sCsvStr .= '"' . str_replace('"', '""', strval($view_reg_master_netsales->CreditAmt->CurrentValue)) . '",';
				$sCsvStr .= '"' . str_replace('"', '""', strval($view_reg_master_netsales->LunchAmt->CurrentValue)) . '",';
				$sCsvStr .= '"' . str_replace('"', '""', strval($view_reg_master_netsales->PayoutAmt->CurrentValue)) . '",';
				$sCsvStr .= '"' . str_replace('"', '""', strval($view_reg_master_netsales->z340B->CurrentValue)) . '",';
				$sCsvStr .= '"' . str_replace('"', '""', strval($view_reg_master_netsales->R228CI29->CurrentValue)) . '",';
				$sCsvStr .= '"' . str_replace('"', '""', strval($view_reg_master_netsales->Kinray->CurrentValue)) . '",';
				$sCsvStr .= '"' . str_replace('"', '""', strval($view_reg_master_netsales->CashAdj->CurrentValue)) . '",';
				$sCsvStr .= '"' . str_replace('"', '""', strval($view_reg_master_netsales->OverAmt->CurrentValue)) . '",';
				$sCsvStr = substr($sCsvStr, 0, strlen($sCsvStr)-1); // Remove last comma
				$sCsvStr .= "\n";
			}
		}
		$rs->MoveNext();
	}

	// Close recordset
	$rs->Close();
	if ($view_reg_master_netsales->Export == "csv") {
		echo $sCsvStr;
	}
}
?>
<?php

// Page Load event
function Page_Load() {

	//echo "Page Load";
}

// Page Unload event
function Page_Unload() {

	//echo "Page Unload";
}
?>
